Posts

Protractor: Data driven testing

We can iterate jasmine "it" blocks with custom data easily by passing  some array or some other external objects as follows:


var testParams = testConfig.testArray; testParams.map(function(testSpec) { it('write your test here', function() { //test code here }); });
Here we are using javascript map function without using any foreach loops as map function internally iterates over the passed array values the given "it"  block.

How to write custom failure messages for expect in Protractor/Jasmine reports

In Protractor ,We can override the error messaging in the Jasmine reporter by defining the custom matcher in the global scope and overrding the default message variable as follows:


beforeEach(function () { jasmine.addMatchers({ toReport: function () { return { compare: function (actual, expected, msg) { var result = {pass: actual == expected}; result.message = msg; return result; } } } }); });And it can be used in expect statements like below inside err function block:expect(false).toReport(true, "Unable to perform required operation because of " + err.message);

Simplified Test Automation Framework with Geb & Spock

Image

Testing Webservice with SoapUI Having Windows Authentication

Sometims SoapUI doesn't seem to work directly with NTLM authentication, but you can use a proxy such as Burp Suite to do the auth for you.


Following are the steps you can perform:

Burp Suite Configuration
    Download Burp Suite from http://portswigger.net/burp/ and set it up.
    On Burp's "Proxy : Intercept" tab, click the button to turn intercept off.
    On Burp's "Proxy : Options" tab, make sure it's set to an unused port, the default is 8081
    On Burp's "Options" tab, tick "do www authentication" and add a setting for the server you wish to hit. Also tick "prompt for credentials on authentication failure"
    Switch to Burp's "Proxy : History" tab so you can see requests going through.

SoapUI Settings
    In SoapUI, choose File > Preferences, then select "Proxy Settings". Enter Host "localhost" and port "8081".
    Use SoapUI as normal. It will send requests thro…

Cucumber and Capybara , How to Submit a Form Without a Button

Sometimes We run into  a problem where we need to submit a form after entering data but there is no specific button or link available on which we can perform operation to submit the form.so I am going to suggest few solutions today for these situations in few different ways so that any one can use the solution depending on his specific situation.


Where we can hit "Enter" to submit the form:

We can access the selenium send_keys method to invoke a return event like
 find_field('field2').native.send_key(:enter)
Using  java script:
 When /^I submit the form$/ do
  page.evaluate_script("document.forms[0].submit()")
end
Without Using java Script:
     we can handle this directly using Racktest(Capybara's default driver)
  When /^I submit the "([^\"]*)" form$/ do |form_id|
    element = find_by_id(form_id)
    Capybara::RackTest::Form.new(page.driver, element.native).submit :name => nil
  end
Where we cannot hit "Enter" to submit :


  We can click…

How to Use Object Repository in Xml format In Selenium Webdriver

Image
You can use XML as object repository like
 And you can use the code for retrieve the objects from xml below is the code:

How to Re-run Failed Scenarios in Cucumber

Usually we require to rerun the failed test cases again once they are fixed or for double verification.In cucumber we can do that easily without developing any customize code for it.


Cucumber directly supports the feature to re- run the failed test cases as following:

Run Cucumber with rerun formatter simply using :

cucumber -f rerun --out rerun.txt
It will output locations of all failed scenarios to the file.

Then you can rerun them by using

cucumber @rerun.txt
This can be further bundled as a rake task and can be run simply as :

require 'cucumber'
require 'cucumber/rake/task'

Cucumber::Rake::Task.new(:jenkins_with_rerun) do |t|
  cucumber -f rerun --out rerun.txt

  cucumber @rerun.txt
end

task :default => :jenkins_with_rerun
 And then can be run as simply "rake" inside the project folder:
C:/>ProjectFolder>rake