Windows Desktop App Automation using Selenium-Cucumber

The very first thing will come in your mind when you read the title is WHAT ???

Then Is it possible ??? Are you sure??? Selenium and windows desktop???

But,

Yeah . . . We are introducing Windows Desktop App automation using selenium-cucumber SOON…

Watch Demo Video

Posted in Uncategorized | 2 Comments

Selenium 3.0 & Gecko Driver

If you recently updated to selenium version 3.0 then you may face issue for lunching Firefox browser.

Like other browsers you have to use driver for Firefox as well if you are using selenium version 3.0 and above.

Mozilla has released geckodriver. You can download the latest executable on the GitHub page.

Download geckodriver according to your platform and simply put into system path and you are ready to use Firefox with Selenium 3.0

Read more about selenium 3.0 here.

Posted in Uncategorized | Leave a comment

Practice is key to success…

Now you can do practice, try snippets on our sample test-page.

http://selenium-cucumber.github.io/

Posted in selenium-cucumber ruby | Leave a comment

Introducing Android Web & App Automation

Need of Mobile Web and App Automation:

  • Now-a-days mobiles are playing most important part in our life. Using mobile web and apps your needs are just one touch away from you.
  • In future people will get everything they want using their mobiles. So as a QA it is our responsibility to deliver quality products on mobiles to the users.
  • Before delivering product we need to test it on multiple devices as there are variety of  mobile models available in the market.
  • Obviously manual testing has its own drawbacks, NO NEED TO EXPLAIN!
  • So instead of testing the applications on multiple devices manually, it is always better to automate the application.

What is easy solution to automate Mobile Web and App:

  • Selenium-cucumber and Appium is easy and efficient tool to automate Mobile Web and Apps.
  • Selenium-cucumber provides Predefined-Steps which are simple English sentences to write Automation test scripts.
  • Appium is an open source mobile automation tool. Appium is basically an HTTP server which handles interaction between your Automation test scripts and mobile device.

Go ahead and see how to do it?

Great thanks to :

  • Appium Contributors

Thanks for your valuable inputs :

  • Dinesh Biradar
  • Sandeep Singh
  • Swapnil Kotwal
Posted in Android Web & App Automation, selenium-cucumber ruby | Tagged , , , , , , , , , , , , , , , | 2 Comments

Locating elements of Android application

There are multiple ways to do same thing but, we always prefer the optimized way. Same is the case for locating Android app elements.

You can locate Android app elements using :

  • uiautomatorviewer
  • Appium inspector

uiautomatorviewer

The uiautomatorviewer is GUI tool to scan and analyze the UI components of an Android application.  It provides a convenient visual interface to inspect the layout hierarchy and view the properties of the individual UI components that are displayed on the test device.

How to use a uiautomatorviewer.

  • Connect Android device to the PC using a USB cable and enable USB debugging option from “Settings -> Developer options” .

Developer_options

  • Launch your test application manually by tapping on the application icon (Here we are using Calculator app).

Calculator_app

  • Now open command prompt/terminal and hit command uiautomatorviewer. This command will open an empty uiautomatorviewer window.

Image_1

  • Click on Device Screenshot or Device Screenshot with Compressed Hierarchy option (2nd and 3rd option in upper left corner). You will get screenshot of currently open view of app on your device. (In our case android calculator screenshot get displayed)

Image_2

  • Now click on app element whose information you want, element will get highlighted in red and you will get element information under Node Details section in uiautomatorviewer window . (In our case lets consider we want information of key 8 of Calculator)

Image_3

  • Now we have index, text, resource-id,class, package and other info. You can use resource-id of element in script to locate element by id (In our case resource-id of key 8 is “com.android2.calculator3:id/digit8”)

Image_4

  • If any element does not have id then use xpath to locate the element. (Lets consider after tapping on key 8 you want to assert text 8).

Image_5

  • To write your xpath:
    a. Start with the class //class
    b. Add attributes @attribute=”attribute_value”
    E.g.: XPath to identify the text 8 in the calculator app is “//android.widget.EditText[@index=0]”. We can use ‘text’, ‘content description’ and other attribute to write xpath.

Appium inspector

To get information about Appium Inspector refer this link.

Posted in Android Web & App Automation, selenium-cucumber ruby | Tagged , , , , , , , , , , , , , , , , | 2 Comments

Android Web & App Automation

Coming Soon…

 

Posted in selenium-cucumber ruby | Tagged , , , , , , , , , , , , , | Leave a comment

Make your automation script more Readable! Meaningful! Maintainable!

Just writing automation script with predefined steps is not enough! It will be easy to write but difficult to understand and maintain in near future. Let’s take example of Facebook Sign-In.

Feature: Facebook Sign-In
         As a user I should able to sign-in into Facebook.
 
 Scenario: Sign-In with valid credential
        Given I navigate to "https://www.facebook.com/"
        And I enter "abc@gmail.com" into input field having id "email"
        And I enter "123456" into input field having id "pass"
        Then I click on element having id "loginbutton"
        And I wait for 15 sec
  • Easy to write – Just copy & paste predefined steps and put parameters.

But

  • It’s not looking meaning-full.
  • Need to guess/verify on which field interaction is going on.
  • The user data (login credentails, test link) and object data (i.e. elements id, class, xpath) may changes, then need to do changes in script, multiple times.

Now let’s garnish above steps with meaning-full sentences.

Feature: Facebook Sign-In
         As a user I should able to sign-in into Facebook.
 
 Scenario: Sign-In with valid credential
        Given I open Facebook login page
        And enter username as "abc@gmail.com"
        And enter password as "123456"
        Then I click on login button
        And I wait for 15 sec

Run script and get implementation suggestions as follows.

You can implement step definitions for undefined steps with these snippets:

Given(/^I open Facebook login page$/) do |arg1|
  pending # express the regexp above with the code you wish you had
end

And(/^enter username as "(.*?)"$/) do |arg1|
  pending # express the regexp above with the code you wish you had
end

And(/^enter password as "(.*?)"$/) do |arg1|
  pending # express the regexp above with the code you wish you had
end

When(/^I click on login button $/) do 
  pending # express the regexp above with the code you wish you had
end

Now copy above steps and implement it in custom_steps.rb under steps_definitions like following.

# custom_steps.rb

require 'selenium-cucumber'

Given(/^I open Facebook login page$/) do
 step %[I navigate to "https://www.facebook.com/"]
end

And(/^enter username as "(.*?)"$/) do |arg1|
  step %[I enter "#{arg1}" into input field having id "email"]
end

And(/^enter password as "(.*?)"$/) do |arg1|
  step %[I enter "#{arg1}" into input field having id "pass"]
end

When(/^I click on login button$/) do
  step %[I click on element with id "loginbutton"]
end
  • Still object data (i.e. elements id, class, xpath) are hard-code and might be used multiple times.
  • So let’s create object_repo(page_objects) which contains variables which will store elements’ locators.
# object_repo.rb

$test_link = 'https://www.facebook.com/'
$username_textfield = 'email'
$password_textfield = 'pass'
$login_button = 'loginbutton'

Using object_repo

# custom_steps.rb

require 'selenium-cucumber'
require 'object_repo'

Given(/^I open Facebook login page$/) do
 step %[I navigate to "#{$test_link}"]
end

And(/^enter username as "(.*?)"$/) do |arg1|
  step %[I enter "#{arg1}" into input field having id "#{$username_textfield}"]
end

And(/^enter password as "(.*?)"$/) do |arg1|
  step %[I enter "#{arg1}" into input field having id "{$password_textfield}"]
end

When(/^I click on login button$/) do
  step %[I click on element with id "#{$login_button}"]
end

So overall structure become like this: structure

This way you can make your automation script more readable! meaningful! maintainable! Thank you readers!

Posted in Uncategorized | 10 Comments

Selenium-Cucumber : Test-Case Verification Steps

Posted in selenium-cucumber ruby | 5 Comments

Selenium-Cucumber : Why? What? How?

the-branding-trinity

Selenium-Cucumber : Why ?

  • This platform of selenium-cucumber is like a boon, especially for ruby lovers.
  • To make your life easier with minimal coding and more of testing, here is a chance for you to try interesting stuff with selenium-cucumber.
  • Also it is of a great help for non-technical people who need not have any coding knowledge.

Selenium-Cucumber : What ?

  • Selenium-Cucumber has its own pre-defined steps for testers to reduce their time and efforts in writing many lines of code to test the web applications.
  • It has the API’s for code efficiency in case you are interested in writing custom code for testing web applications.
  • Creating well formatted test reports.
  • More than all it is cross-platform, open source and free.

Selenium-Cucumber : How ?

  • Few simple steps to follow and you can test your entire web application!!
  • You need to have Ruby installed on your machines.
  • Following few commands.
> gem install selenium-cucumber
> selenium-cucumber gen
> cucumber
Posted in selenium-cucumber ruby | 2 Comments

selenium-cucumber : Image Comparing Steps

Now easily compare images/logos from website under test using

Image Assertion Steps

Pass appropriate locator of “actual image” and URL of “expected images” (which you can store on some server) to following steps to compare images/logos from testing website :

Then actual image having id "(.*?)" and expected image having url "(.*?)" should be similar
Then actual image having name "(.*?)" and expected image having url "(.*?)" should be similar
Then actual image having class "(.*?)" and expected image having url "(.*?)" should be similar
Then actual image having xpath "(.*?)" and expected image having url "(.*?)" should be similar
Then actual image having css "(.*?)" and expected image having url "(.*?)" should be similar
Then actual image having url "(.*?)" and expected image having url "(.*?)" should be similar

Pass appropriate locator of “actual image” and image name of “expected images” (which you can store locally on you machine under “expected_images” folder in feature skeleton) to following steps to compare images/logos from testing website :

Then actual image having id "(.*?)" and expected image having image_name "(.*?)" should be similar
Then actual image having name "(.*?)" and expected image having image_name "(.*?)" should be similar
Then actual image having class "(.*?)" and expected image having image_name "(.*?)" should be similar
Then actual image having xpath "(.*?)" and expected image having image_name "(.*?)" should be similar
Then actual image having css "(.*?)" and expected image having image_name "(.*?)" should be similar
Then actual image having url "(.*?)" and expected image having image_name "(.*?)" should be similar

To compare two images from same webpage you can make use following steps.

Then actual image having id "(.*?)" and expected image having id "(.*?)" should be similar
Then actual image having name "(.*?)" and expected image having name "(.*?)" should be similar
Then actual image having class "(.*?)" and expected image having class "(.*?)" should be similar
Then actual image having xpath "(.*?)" and expected image having xpath "(.*?)" should be similar
Then actual image having css "(.*?)" and expected image having css "(.*?)" should be similar
Then actual image having url "(.*?)" and expected image having url "(.*?)" should be similar
  • If any difference appears in actual image and expected images then difference between images will be highlighted and stored in “image_difference” directory in feature skeleton. (Note : This feature works only for PNG images.)
  • You can avail “Image Assertion Steps” for gem version 1.1.1 and above.
  • From gem version 1.1.1 and above feature skeleton is slightly changed. We have introduced four more directories “expected_images”, “image_difference”, “actual_images”,”screenshots” in feature skeleton.

Video tutorial about how to use image assertion steps.

Posted in selenium-cucumber ruby | Tagged , , , , , , , | 2 Comments