Android apps to use in appium android test examples

Breaking

Tuesday, September 19, 2017

Selenium WebDriver DDF : Creating Function To Get Element From Page

We convey created object repository In selenium webdriver information driven framework creation STEP 27. So now, our all spider web element's xpath or CSSPath or whatever other locators volition hold upwards stored In object repository Instead of examination cases files. Now permit us endeavour to compact webdriver code past times creating getElementByXPath share to provide spider web page chemical ingredient on demand.

STEP 28
Prerequisite : Previous 27 Steps Of WebDriver information driven framework creation listed on THIS PAGE should hold upwards Implemented.

getElementByXPath Function
I convey created two getElementByXPath functions In SuiteBase.java shape to instruct Its access In all examination cases. First getElementByXPath function has exclusively i Input parameter together with minute overloaded method has iii Input parameters equally bellow.

getElementByXPath(String) getElementByXPath(String, int, String)

  • In first getElementByXPath function, You convey to overstep spider web element's xpath substitution value equally Input. The code of this share volition locate together with provide the chemical ingredient from spider web page If found. Else It volition provide null.
  • In minute getElementByXPath function, You convey to overstep spider web element's xpath key1(1st share of xpath), Integer Value and xpath key2(2nd share of xpath). These iii Input parameters volition practise amount XPath for spider web chemical ingredient together with code of this share volition locate together with provide chemical ingredient from the spider web page If found. Else It volition provide null.
You volition break both these functions In SuiteBase.java class file when y'all download Step 28.zip folder at bellow.

How To Use getElementByXPath Function In Test Cases
If y'all convey unmarried substitution of xpath together with then y'all tin sack exercise getElementByXPath share equally bellow. It volition click on push whose substitution Is 'btn_Plus' In Objects.properties object repository file.
Example : 
getElementByXPath("btn_Plus").click();

If y'all convey to construct dynamic xpath of chemical ingredient together with then y'all tin sack use getElementByXPath function as bellow. Here nosotros are sending 3 parameters to getElementByXPath share to construct amount xpath of element. btn_Calc_PrePart and btn_Calc_PostPart are static together with volition hold upwards retrieved from Objects.properties object repository file. ValueOne can hold upwards whatever Integer value hence nosotros tin sack refer It dynamic xpath generation.
Example :
getElementByXPath("btn_Calc_PrePart",ValueOne,"btn_Calc_PostPart").click();

I convey Implemented both these functions In SuiteOneCaseOne.java examination illustration file to hollo back chemical ingredient from spider web page.

Download Required Files
You postulate to download SuiteOneCaseOne.java and SuiteBase.java modified files. You volition instruct both these files In bellow given zip folder.
Extract the folder together with replace SuiteOneCaseOne.java and SuiteBase.java files amongst existing files In eclipse.

Running Test
Now y'all tin sack run your examination from .bat file together with break the execution. There Is non whatever menses modify In this pace but only break that y'all are non getting whatever mistake during execution.

If y'all non sympathize how getElementByXPath share Is working together with then position interruption quest In your examination illustration together with run your examination In debug agency from testng.xml file together with debug pace past times pace execution. Let me know If y'all convey whatever enquiry In this pace past times commenting bellow.

What We Have Achieved In This Step
We convey Implemented getElementByXPath share In our information driven framework to instruct spider web chemical ingredient from the page. This volition compact your webdriver code size together with volition brand examination cases slow to understand.



More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM http://www.software-testing-tutorials-automation.com/

No comments:

Post a Comment