Android apps to use in appium android test examples

Breaking

Wednesday, September 20, 2017

Selenium WebDriver DDF : Creating Object Repository To Store Element Objects

In Selenium WebDriver software seek out information driven framework creation STEP 26, We convey Implemented uncomplicated calc software test. Now In this step, We volition exercise object repository using .properties file to shop software spider web page element's locators similar xpath Locator, cssSelector Locator, className Locator, id Locator, linkText Locator, name Locator,
partialLinkText Locator as well as tagName Locator. We tin telephone outcry upward It equally object repository because nosotros are storing objects In that .properties file.
STEP 27
Prerequisite : All the previous 26 Steps of selenium webdriver DDF creation should locomote Implemented. You tin teach links of all previous steps on THIS PAGE.

Why need to exercise object repository?
Supposing yous convey 100 software seek out cases as well as at that topographic point Is ane push or text box or whatever other chemical component which Is used In l software seek out cases. Now for unopen to reason, XPath or id or cssSelector locator of that chemical component Is changed on software spider web page which yous convey used In l seek out cases. In this province of affairs what yous volition do? You volition teach to alter element's locator In all l seek out cases? It Is only waste materials of fourth dimension as well as It volition exercise many complexity as well as errors In code.

Best agency to receive got this province of affairs Is creating object repository. As described In commencement paragraph, Object repository volition shop the chemical component objects. So yous need to shop all the element's objects In unmarried .properties file as well as hence you can occupation It's fundamental In your seek out cases wherever required. Now If higher upward scenario happens hence yous convey to modify your element's locator In .properties file only.

How to exercise object repository
For creating object repository, You convey to Insert novel file Objects.properties under com.stta.property packet to shop element's locators.

How to telephone outcry upward object from Objects.properties file
First of all, We convey to Initialize Objects.properties file earlier seek out illustration execution. So nosotros will Initialize It Inside init() purpose of SuiteBase.java file. And hence nosotros tin telephone outcry upward whatever object Inside our seek out illustration using It's key.

Example :
Supposing, at that topographic point Is ane push +(plus) In calc application whose XPath Is "//input[@id='plus']". So yous tin shop It In Objects.properties file equally bellow.

btn_Plus=//input[@id='plus']

Here btn_Plus Is the fundamental of that XPath. So immediately If yous wants to click on that push In your seek out illustration hence yous tin occupation bellow given syntax In your seek out case.

driver.findElement(By.xpath(Object.getProperty("btn_Plus"))).click();

This Is Just example, Same agency yous tin telephone outcry upward all other required objects In your seek out cases from Objects.properties file.

Download required files
You need modified Objects.properties, SuiteBase.java as well as SuiteOneCaseOne.java files. Download bellow given naught folder to teach all these files.
Add/Replace files equally bellow
  • Add Objects.properties Under com.stta.property Package
  • Paste SuiteBase.java File on com.stta.TestSuiteBase Package.
  • Paste SuiteOneCaseOne.java File on com.stta.SuiteOne Package.
Now your projection construction volition looks similar bellow.

I convey added comments In SuiteBase.java and SuiteOneCaseOne.java files to empathize code better.

Run seek out suites as well as detect results
Run your seek out from Shortcut to Run Test.bat file. Now SuiteOneCaseOne.java will read element's objects from Objects.properties file.

What nosotros convey achieved In this step
We convey created object repository for our selenium webdriver information driven framework. So from immediately onward, nosotros volition shop all our objects In Objects.properties file. Benefits of creating object repository In webdriver DDF are equally bellow.
  • Easy to hold the software spider web page's objects elements.
  • Decrease the size of code.


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

No comments:

Post a Comment