Calabash only supports web view which is in build in mobile application and not supported web application opened on mobile browser. I have searched such type application and finally got from MonketTalk sample application. In this I have created step definition and automated below form:
Road to identifying elements using Calabash's query command
In this post, I will show you the way, how to identify application elements. Before going below, make sure you resigned and created test server of your application.
Now open commands prompt, go to directory application and run below command:
Calabash console should be opened. Following are the some basic way to find element details using query commands.
Now open commands prompt, go to directory application and run below command:
calabash-android console {ApkfileName}
Road to data driven testing in SoapUI using groovy script with excel file
SoapUI Pro has a feature to read data from external files like: excel, csv etc. But SoapUI does not provide such feature to read data from excel file. So for reading data from excel file in SoapUI, we need to write some code in groovy script.
I this post I will show you, how to read data from excel file.I am using poi jar files to read data from excel file in groovy, download following jar files and put into SoapUI lib folder.
I this post I will show you, how to read data from excel file.I am using poi jar files to read data from excel file in groovy, download following jar files and put into SoapUI lib folder.
- poi-3.8-beta5-20111217.jar
- poi-examples-3.8-beta5-20111217.jar
- poi-excelant-3.8-beta5-20111217.jar
- poi-ooxml-3.8-beta5-20111217.jar
- poi-ooxml-schemas-3.8-beta5-20111217.jar
- poi-scratchpad-3.8-beta5-20111217.jar
- dom4j-1.6.1.jar
Script assertion in Soap UI for WSDL API methods
In this post I will show you how to add script assertion in SoapUI response of wsdl api test methods.
Here I have an example of CurrencyConvertor, I created a SoapUI project and added test case for this method as you can see in below window.
Now here in response body I will add assertion that verify the “ConversionRateResult” value is always 104 for given input value.
Here I have an example of CurrencyConvertor, I created a SoapUI project and added test case for this method as you can see in below window.
Now here in response body I will add assertion that verify the “ConversionRateResult” value is always 104 for given input value.
BDD framework in Webdriver using C#
In my previous post, I have posted BDD framework in Webdriver using Java. In this post I will show you how to create BDD framework using C#. To achieve this I will use SpecFlow. This is same as Cucumber and you can write specs (features) file by using the same Gherkin language.
Setup:
1. Install Visual studio.
2. Download and install SpecFlow from link :”click” For more detail about SpecFlow go to link ”click”
3. Download NUnit Test Adapter from link:”click”.
Steps to create project:
1. Go to File >>New >>Project and click.
2. Select Visual C# >> Class Library.
3. Enter project name into name filed and click on "OK" button, as below screen.
Setup:
1. Install Visual studio.
2. Download and install SpecFlow from link :”click” For more detail about SpecFlow go to link ”click”
3. Download NUnit Test Adapter from link:”click”.
Steps to create project:
1. Go to File >>New >>Project and click.
2. Select Visual C# >> Class Library.
3. Enter project name into name filed and click on "OK" button, as below screen.
Java WebDriver BDD framework using Cucumber-JVM
In this post I will show you how to create BDD framework in webdriver selenium using cucumber-jvm. Cucumber –JVM is based on cucumber framework which allows to writes feature file in plain text using Gherkin language, This feature is supported by step definitions file which has implemented automation code of Webdriver.
This post cover maven based java webdriver BDD framework using cucumber for Google advance search scenario, Following are the steps to write scenario for BDD framework:
1. First create a maven eclipse project.
This post cover maven based java webdriver BDD framework using cucumber for Google advance search scenario, Following are the steps to write scenario for BDD framework:
1. First create a maven eclipse project.
WebdriverBDD
src/main/java
src/test/java
******** com/maven/test
src/test/resources
******** com/maven/test
pom.xml
Java junit client of WSDL webservices
In this post, I will show you how to create java client for WSDL web services.
I will Create a example of currency converter, This is wsdl URL for same. “currency converter”
Request of “ConversionRate” method:
I will Create a example of currency converter, This is wsdl URL for same. “currency converter”
Request of “ConversionRate” method:
Webdriver implicit and explicit wait for element locator.
Today most of web application using Ajax, When page is load some element load in a different time of interval or some time request send without page loading if the element not present then it through element not found exception or not visible element etc.. To handle this Webdriver provides two type of wait “implicit” and “explicit” wait
Implicit Wait: implicit wait provide to load DOM object for a particular of time before trying to locate element on page. Default implicit wait is 0. We need to set implicit wait once and it apply for whole life of Webdriver object. Add below line of code in test for implicit wait. However implicit wait slow down execution of your test scripts if your application responding normally.
Implicit Wait: implicit wait provide to load DOM object for a particular of time before trying to locate element on page. Default implicit wait is 0. We need to set implicit wait once and it apply for whole life of Webdriver object. Add below line of code in test for implicit wait. However implicit wait slow down execution of your test scripts if your application responding normally.
driver.manage().timeouts().implicitlyWait(30,
TimeUnit.SECONDS);
Calabash android predefined steps.
Calabash android has some predefined steps, you don’t need to define these steps in your steps definition ruby file. Just call these functions in your feature file by passing valid argument.
Assertion steps:
Following are the some steps definition for the assertion
Assertion steps:
Following are the some steps definition for the assertion
Then /^I see
the text "([^\"]*)"$/
Then /^I see
"([^\"]*)"$/
Then /^I
should see "([^\"]*)"$/ do
Then /^I
should see text containing "([^\"]*)"$/ do
Then /^I
should not see "([^\"]*)"$/ do
Then /^I
don't see the text "([^\"]*)"$/ do
Then /^the
view with id "([^\"]*)" should have property
"([^\"]*)" = "([^\"]*)"$/ do
Then /^the
"([^\"]*)" activity should be open$/ do
Road to verify css properties value using Webdriver
To get css values of any locator, we will create java script function with the use of “getDefaultComputedStyle”function. We will execute java script function using webdriver and fetch css properties value.
getDefaultComputedStyle () gives default computed value of all css properties of an element.
Here I have created a sample example in which I am verifying Google home page menu bar css properties color, height and width.
getDefaultComputedStyle () gives default computed value of all css properties of an element.
Here I have created a sample example in which I am verifying Google home page menu bar css properties color, height and width.
package
com.test;
import
java.util.concurrent.TimeUnit;
import
org.openqa.selenium.JavascriptExecutor;
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.firefox.FirefoxDriver;
import
org.testng.Assert;
import
org.testng.annotations.AfterSuite;
import
org.testng.annotations.BeforeSuite;
import
org.testng.annotations.Test;
public class
WebdriverCSSValue {
private WebDriver driver;
private String baseUrl;
@BeforeSuite
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl =
"https://www.google.co.in/";
driver.manage().timeouts().implicitlyWait(30,
TimeUnit.SECONDS);
}
@Test
public void testCSSvalueVerifying() {
driver.get(baseUrl +
"/");
// js scripts
String js = "return
window.document.defaultView.getComputedStyle(" +
"window.document.getElementById('gbx3'))";
String jsColor =
js+".getPropertyValue('color')";
String jsHeight =
js+".getPropertyValue('height')";
String jswidth =
js+".getPropertyValue('width')";
// execution of js scripts to
fetch css values
JavascriptExecutor jsexecuter =
(JavascriptExecutor) driver;
String color = (String)
jsexecuter.executeScript(jsColor);
String height = (String)
jsexecuter.executeScript(jsHeight);
String width = (String)
jsexecuter.executeScript(jswidth);
//assertion
Assert.assertTrue(color.equals("rgb(34,
34, 34)"));
Assert.assertTrue(width.equals("986px"));
Assert.assertTrue(height.equals("29px"));
// print css values
System.out.println(color);
System.out.println(height);
System.out.println(width);
}
@AfterSuite
public void tearDown() throws Exception {
driver.quit();
}
Ruby WebDriver – procedure to create test scripts in RSpec
Setup of Ruby and Selenium 2:
1. Download ruby setup file from url http://rubyinstaller.org/downloads . Install the executable file into your system and set Ruby as Environmental variable into your system.
2. Open command prompt and check “ruby -v “ to verify ruby installation and path setup.
3. After ruby installation run below command for selenium2 installation.
4. Run below command for Rspec.
5. For more detail about RSpec go to link “http://rspec.info/”
1. Download ruby setup file from url http://rubyinstaller.org/downloads . Install the executable file into your system and set Ruby as Environmental variable into your system.
2. Open command prompt and check “ruby -v “ to verify ruby installation and path setup.
3. After ruby installation run below command for selenium2 installation.
gem install
selenium-webdriver
gem install rspec
Integration of Junit test with Jmeter
In this post I will show you how to integrate and execute Junit test with Jmeter .
Junit test:
Here I have created two Junit test:
1. JunitFirstTest.java:
Junit test:
Here I have created two Junit test:
1. JunitFirstTest.java:
package com.test;
import org.junit.*;
public class JunitFirstTest {
@BeforeClass
public static void beforeClassAnnotation() {
System.out.println("@BeforeClass
- for junit class 1");
}
@AfterClass
public static void afterClassAnnotation() {
System.out.println("@AfterClass
- for junit class 1");
}
@Test
public void testAnnotation() {
System.out.println("@Test - first class test method");
}
}
Road to integration of WebDriver test script with TestLink
TestLink Installation: Test link installation you first need to go this link click here
TestLink Setup for Automation:
1. First you need to enable Automation (API keys) of your test link project.
Open your testlink project, click on check box of “Enable Test Automation (API keys)” and click on save button.
2. Generate Key: This key provide interface between webdriver test scripts and testlink. You must generate this key. To generate this click on >> My Settings menu and click on “Generate a new key” button under “API interface” section.
TestLink Setup for Automation:
1. First you need to enable Automation (API keys) of your test link project.
Open your testlink project, click on check box of “Enable Test Automation (API keys)” and click on save button.
2. Generate Key: This key provide interface between webdriver test scripts and testlink. You must generate this key. To generate this click on >> My Settings menu and click on “Generate a new key” button under “API interface” section.
3. Create test link project.
4. Create test link plan and add test plan to created test link project.
5. Create test suite and test cases under created test link project.
4. Create test link plan and add test plan to created test link project.
5. Create test suite and test cases under created test link project.
How to install and setup Testlink on window machine?
Perquisite:
- Download and install xampp application into your machine from link: "http://www.apachefriends.org/en/xampp-windows.html"
- Download testlink from link "http://sourceforge.net/projects/testlink/files/" and put into xampp's htdocs directory.
- Extract downloaded zip file into xampp's htdocs directory.
- Start Xampp application and start “Apache” and “MySql” Server, your window look like below screen:
Road to handle file download popup in webdriver using Sikuli
In this post I will show you how to integrate webdriver test script with Sikuli automation tool to handle window popup utility like file download and upload etc.
Here I take example of a file download window popup utility, which we can not handle by using webdriver functions. Some people use different-2 automation tool like AutoIt, java Robot class to handle this.
Here is an example of webdriver sikuli integration to handle below selenium jar file download window popup utility.
Here I take example of a file download window popup utility, which we can not handle by using webdriver functions. Some people use different-2 automation tool like AutoIt, java Robot class to handle this.
Here is an example of webdriver sikuli integration to handle below selenium jar file download window popup utility.
Some Webdriver API functions in java and its implementation
Following are the some API functions and it implementation
1. How to click on element: By using click() function we perform click operation on page element:
2. How to enter text into page element: By using sendkeys() function we enter text in page element such as text field, area etc:
3. How to count total number rows in table:
1. How to click on element: By using click() function we perform click operation on page element:
WebElement el = driver.findElement(By.id("ElementID"));
el.click();
WebElement el = driver.findElement(By.id("ElementID"));
el.clear(); //use to clear input
field
el. sendKeys (“User name”);
3. How to count total number rows in table:
List rows =
driver.findElements(By.className("//table[@id='tableID']/tr"));
int totalRow = rows.size();
Road to data driven testing in SoapUI from csv file
In this post I will show you how to execute SoapUI test for a set of values. For this I have put all data in csv file. I write groovy scripts for reading data from csv and executing the test steps.
Below is the groovy script for reading data from “URL.csv” file where I put all user credentials.
In above code I read data from “URL.csv” file and pass user name and password into “UserName “ and “Pass” of Login steps parameters.
Below is the groovy script for reading data from “URL.csv” file where I put all user credentials.
def groovyUtils = new
com.eviware.soapui.support.GroovyUtils(context)
def csvFilePath = "D:\\URL.csv"
context.fileReader = new BufferedReader(new
FileReader(csvFilePath))
rowsData = context.fileReader.readLines()
int rowsize = rowsData.size()
for(int i =0; I < rowsize; i++)
{
rowdata
= rowsData[i]
String[]
data = rowdata.split(",")
log.info
data[1]
groovyUtils.setPropertyValue("Login",
"UserName", data[0])
groovyUtils.setPropertyValue("Login",
"Pass", data[1])
testRunner.runTestStepByName(
"Login")
}
In above code I read data from “URL.csv” file and pass user name and password into “UserName “ and “Pass” of Login steps parameters.
“Login” test step executed by using test runner for every data.
Road to reading data from text file in SoapUI using groovy script
In this post, I am going to show you how to read data from text file in SoapUI. SoapUI Pro has some advance feature which is not in SaopUI as data fetching from external sources so in SoapUI we use Groovy script for that. Following are the peace of groovy script code for reading data from text file.
1. Reading all data from text file.
1. Reading all data from text file.
//reading all txt file at once
File file = new File("D://user.txt")
fileContent = file.getText()
log.info fileContent
2. Reading data line by line from text file.
//reading text line by line
File file1 = new File("D://user.txt")
List textLine = file1.readLines()
log.info textLine
3. Reading data randomly of any line from text file.
//reading text randon line number
File file2 = new File("D://user.txt")
List textLine2 = file2.readLines()
rowIndex
= Math.abs(new Random().nextInt()
% 4 + 1)
log.info textLine2[rowIndex]
Road to handle popup window using text in Webdriver
Some times we have not title of pop window so in this case we can identified some unique text (content ) of popup window which is not in other window. Using this text we can switch to pop window. Below are the logic and implemented code.
Road to installation of SoapUI plugin into Eclipse.
Following are the steps to install soapui plug-in into eclipse.
1. Open Eclipse IDE and goto “Help” menu and click on “Install New Software”
2. Click on add button you should see like below window.
1. Open Eclipse IDE and goto “Help” menu and click on “Install New Software”
2. Click on add button you should see like below window.
3. Enter some text into “name” field as “SoapUI“ and enter url http://www.soapui.org/eclipse/update into “Location” field.
4. Click on “OK” button, you should see below screen and soapUI will display.
Execution of SoapUI project using Junit
In this post I am going to show you how to execute SoapUI project using Junit.
SoapUI provide testrunner class name “SoapUITestCaseRunner” which can be used to run soapui test using java class, maven or ant build tool. We create object of this class in java file and call the run function to execute soapui project.
Steps to create Junit test for soap ui project:
1. Chose any IDE as eclipse or NetBean
2. Add “soapui-4.5.1.jar” from soapui bin folder and soapui lid folder as library to class path of your project (eclipse).
3. Use “SoapUITestCaseRunner” class object to run soapui project as mentioned in below code:
SoapUI provide testrunner class name “SoapUITestCaseRunner” which can be used to run soapui test using java class, maven or ant build tool. We create object of this class in java file and call the run function to execute soapui project.
Steps to create Junit test for soap ui project:
1. Chose any IDE as eclipse or NetBean
2. Add “soapui-4.5.1.jar” from soapui bin folder and soapui lid folder as library to class path of your project (eclipse).
3. Use “SoapUITestCaseRunner” class object to run soapui project as mentioned in below code:
Road to command line execution of soapUI project
We run SoapUI project using SoapUI GUI interface. SoapUI also provide set off batch files to execute soapUI tests from command line without using SoapUI GUI interface.
Following are the runner scripts inside installed SoapUI bin folder.
1. testrunner.bat : this is use to run functional test using command line.
2. loadtestrunner.bat: This is used to run soapui load testing using command line.
3. mockservicerunner.bat: This is used to run soapui mock services using command line.
4. toolrunner.bat: This is used to launch soapui tools.
5. securitytestrunner.bat: This command is used to run security tests
Following are the runner scripts inside installed SoapUI bin folder.
1. testrunner.bat : this is use to run functional test using command line.
2. loadtestrunner.bat: This is used to run soapui load testing using command line.
3. mockservicerunner.bat: This is used to run soapui mock services using command line.
4. toolrunner.bat: This is used to launch soapui tools.
5. securitytestrunner.bat: This command is used to run security tests
Road to integration of calabash android test with Jenkins
In this post I am going to show you how to integrate calabash android test with Jenkins continuous integration for build. Also I will show you how to publish cucumber execution report in Jenkins.
Installation:
1. Java: java should be installed
2. Jenkins: If you are new to Jenkins then click link "click here” of my post how to setup Jenkins in window before continue.
3. Install the”cucumber-jvm-reports-java” plugin: following are the steps to install plugin.
Installation:
1. Java: java should be installed
2. Jenkins: If you are new to Jenkins then click link "click here” of my post how to setup Jenkins in window before continue.
3. Install the”cucumber-jvm-reports-java” plugin: following are the steps to install plugin.
Road to performance testing using soapUI
In this post I would like to show you performance testing of webservices using soap ui.
Performance testing of web services is not just running SOAP or XML messages in a loop to run the service. It should be a well-planned activity which must be aligned with the performance expectations of the overall service-oriented solution. You can run multiple type of performance test such as SOAP , JSON, XML format messaging through a single interface
SoapUI allows users to configure various load testing options such as delays in between threads to simulate real-world use cases and run tests in burst mode to stress test services.
Performance testing of web services is not just running SOAP or XML messages in a loop to run the service. It should be a well-planned activity which must be aligned with the performance expectations of the overall service-oriented solution. You can run multiple type of performance test such as SOAP , JSON, XML format messaging through a single interface
SoapUI allows users to configure various load testing options such as delays in between threads to simulate real-world use cases and run tests in burst mode to stress test services.
Some Important SoapUI functions in groovy script.
In this post I will show you some important soapui functions which are basically used in soap ui groovy scripts.
1. Following functions are used to read properties in soapui project.
I have create three properties with name "Test" at project, testsuite and test case level. Using above code we can read values in groovy scripts and can be use where needed.
2. Setting properties value test case.
3. Reading end url value of any test steps. Replace your test step name with “TestStepName”
4. Setting parameter value of test steps. Replace you test step name, parameter name and value with “TestStepName”, “dataSet” and “value”.
Will continue adding more function
1. Following functions are used to read properties in soapui project.
projectPropertyValue = context.expand(
'${#Project#Test}')
projectPropertyValue = context.expand(
'${#TestCase#Test}')
projectPropertyValue = context.expand(
'${#TestSuite#Test}'
I have create three properties with name "Test" at project, testsuite and test case level. Using above code we can read values in groovy scripts and can be use where needed.
2. Setting properties value test case.
def myTestCase = context.testCase
myTestCase.setPropertyValue("Name", “Value”)
3. Reading end url value of any test steps. Replace your test step name with “TestStepName”
EndPointUrl = context.getProperty("TestStepName","Endpoint")
def groovyUtils = new
com.eviware.soapui.support.GroovyUtils(context)
//set data parameter value in TestStep
groovyUtils.setPropertyValue("TestStepName",
"dataSet", “value”)
Road to capture clip of element locator in webdriver java
In this post I am going to show you how to capture clip of page element using webdriver.
Below I have written a “CaptureElementClip.java“java webdriver test script of a google application where I capture google menu clip and save into project.
After executing above test a “Menu.png” file is generated in root folder of your project.
Below I have written a “CaptureElementClip.java“java webdriver test script of a google application where I capture google menu clip and save into project.
package com.webdriver.test;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.imageio.ImageIO;
import
org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import
org.openqa.selenium.OutputType;
import org.openqa.selenium.Point;
import
org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import
org.openqa.selenium.firefox.FirefoxDriver;
import
org.testng.annotations.AfterSuite;
import
org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
public class CaptureElementClip {
private WebDriver driver;
private String baseUrl;
@BeforeSuite
public void setUp() throws Exception {
driver
= new FirefoxDriver();
baseUrl
= "http://google.com";
driver.manage().timeouts().implicitlyWait(30,
TimeUnit.SECONDS);
}
@Test
public void testGoogle() throws
IOException {
//open
application url
driver.get(baseUrl);
//take
screen shot
File
screen = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.FILE);
//get
webelement object of google menu locator
WebElement
googleMenu = driver.findElement(By.id("gbz"));
Point
point = googleMenu.getLocation();
//get
element dimension
int
width = googleMenu.getSize().getWidth();
int
height = googleMenu.getSize().getHeight();
BufferedImage
img = ImageIO.read(screen);
BufferedImage
dest = img.getSubimage(point.getX(), point.getY(), width,
height);
ImageIO.write(dest,
"png", screen);
File
file = new File("Menu.png");
FileUtils.copyFile(screen,
file);
}
@AfterSuite
public void tearDown() throws Exception
{
driver.quit();
}
}
After executing above test a “Menu.png” file is generated in root folder of your project.
Subscribe to:
Posts (Atom)