Hey guys this is upcoming Free Webinar by Perfecto and I feel its is very important to attend if you are working with Selenium or you want to learn Selenium. I always believe in attending these types of webniar as they are conducted by experienced people and I always end up learning something new at the end.
If you are passionate about learning then attending this session will ad on something new to you knowledge bucket.
Let us see what so special about thise Webniar which is held on 22nd June11am EST/ 8am PST/ 4pm GMT for India its 8.30 PM IST. -
In this webinar, Automate More with Selenium for your RWD, Perfecto’s Uzi Eilon and Eran Kinsbruner will walk you through several technical challenges and solutions around test automation for responsive sites. See live demos around testing responsive web sites using extended test automation capabilities that can increase your test coverage suite.
You will learn how to: 1.Author basic selenium scripts using a powerful recorder for both mobile and web 2.Define a robust XPath using an innovative free online tool 3.Build a test lab for parallel script execution on multiple devices and browsers 4. Gain high quality analysis post execution with mature digital reporting
Always Spend time in learning something new and click here to Register Now .
This is Free Webinar .
I will also be attending the same so see you all guys ..:-)
Starting an UI Automation in Appium is not a tough task. You just need to locate elements, perform actions on it.
A small Appium test script maintenance looks easy,but ut with time test
suite will grow into multiple test scripts. As you add more and more lines to your code, things
become tough to maintain.The chief problem with script maintenance is that
if 10 different scripts are using the same mobile element, with any change
in that element, you need to change all 10 scripts. This is time
consuming and error prone.
A better approach to test scripts
maintenance is to create a separate class file which would find mobile
elements, fill them or verify them which can be reused in all the
scripts using that element. In future, if there is a change in the web
element, we need to make the change in just 1 class file and not 10
different test scripts.This approach is called Page Object Model(POM). It helps make the code more readable, maintainable, and reusable.
Video Tutorial -
What is POM?
1. Page Object Model is a design pattern.
2. Under this model, for each mobile app screen , there should be corresponding page class.
3. This Page class will find the MobileElements of that mobile screen page and also contains Page methods which perform operations on those MobileElements .
4. Name of these methods should be given as per the task they are performing, i.e., if a loader is waiting for the login page to appear, POM method name can be waitForLoginScreenDisplay().
Advantages of POM
1.Page Object Model defines that operations and test scenario flows in the UI should be separated from verification. This concept makes code cleaner and easier to understand.
2.The Second benefit is the object repository is kept independent of test cases, so we can use the same object repository for a different purpose and with different tools. For example, we can integrate POM with TestNG/JUnit for functional Testing and at the same time with JBehave/Cucumber for acceptance testing.
3.Code becomes reusable and optimized .
How to Use POM?
Core Class for Desired Capabilities related setup -
This class we can use to write core setup related code which is common for executing each Appium test case.
packagecom.example.anuja.appiumapplication;importjava.io.File;importjava.net.MalformedURLException;importjava.net.URL;importjava.util.Properties;importorg.openqa.selenium.remote.CapabilityType;importorg.openqa.selenium.remote.DesiredCapabilities;importorg.testng.annotations.AfterClass;importorg.testng.annotations.BeforeClass;importio.appium.java_client.AppiumDriver;importio.appium.java_client.android.AndroidDriver;importio.appium.java_client.remote.MobileCapabilityType;/** * Created by Anuja on 6/2/2017. */publicclassBaseSetup{privateDesiredCapabilitiescapabilities=newDesiredCapabilities();privatestaticAndroidDriverandroidDriver=null;privateStringappiumPort;privateStringserverIp;@BeforeClasspublicvoidsetup(){initDriver();}publicAndroidDrivergetDriver(){returnandroidDriver;}privatevoidinitDriver(){System.out.println("Inside initDriver method");DesiredCapabilitiescap=newDesiredCapabilities();cap.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");cap.setCapability(MobileCapabilityType.DEVICE_NAME,"Android device");cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT,"4000");cap.setCapability(MobileCapabilityType.APP,"c://apks//listviewsample.apk");cap.setCapability("noReset",true);StringserverUrl="http://"+serverIp+":"+appiumPort+"/wd/hub";try{System.out.println("Argument to driver object : "+serverUrl);androidDriver=newAndroidDriver(newURL(serverUrl),capabilities);}catch(NullPointerException|MalformedURLExceptionex){thrownewRuntimeException("appium driver could not be initialised for device ");}System.out.println("Driver in initdriver is : "+androidDriver);}@AfterClasspublicvoidtearDown(){androidDriver.quit();}}
Driver class -
This class to instantiate driver object.
importio.appium.java_client.android.AndroidDriver;/** * Created by Anuja on 6/2/2017. */publicclassDriverextendsBaseSetup{protectedAndroidDriverdriver;publicDriver(){this.driver=super.getDriver();}}
Page Class for Login Page -
This is how our page class looks.
importorg.openqa.selenium.WebElement;importorg.openqa.selenium.support.CacheLookup;importorg.openqa.selenium.support.FindBy;importorg.openqa.selenium.support.PageFactory;importorg.testng.Assert;/** * Created by Anuja on 5/17/2017. */publicclassLoginPageextendsDriver{PageObjectsloginPage;StringuserName="";StringpassWord="";publicLoginPage(){super();loginPage=newPageObjects();PageFactory.initElements(driver,loginPage);}publicbooleanvalidateLoginpage(){booleanelements=false;if(loginPage.userNameFld.isDisplayed()){if(loginPage.passwordField.isDisplayed()){if(loginPage.checkBox.isDisplayed()){if(loginPage.loginBtn.isDisplayed()){elements=true;}}}}else{elements=false;}returnelements;}publicbooleantestLoginWithoutCredentials(){booleanloginStatus=false;loginPage.loginBtn.click();if(loginPage.inputError.getText().equalsIgnoreCase("Username is mandatory")){loginStatus=true;}loginPage.userNameFld.sendKeys(userName);loginPage.loginBtn.click();if(loginPage.inputError.getText().equalsIgnoreCase("Password is mandatory")){loginStatus=true;}returnloginStatus;}classPageObjects{@CacheLookup@FindBy(id="et_username")publicWebElementuserNameFld;@CacheLookup@FindBy(id="et_password")publicWebElementpasswordField;@CacheLookup@FindBy(id="btnSignin")publicWebElementloginBtn;@CacheLookup@FindBy(name="Invalid ID or password.")publicWebElementinputError;@CacheLookup@FindBy(id="checkBox")publicWebElementcheckBox;}}
Test Case class for writing login page test cases -
This is how our test case is going to look.
importorg.junit.Test;/** * Created by Anuja on 5/17/2017. */publicclassLoginTests{@TestpublicvoidtestLogin(){LoginPageloginPage=newLoginPage();if(loginPage.validateLoginpage()==true){loginPage.testLoginWithoutCredentials();System.out.println("pass");}else{System.out.println("Validation failed");}}}
I hope you like this post. do share your queries and feedback in comment section below and please follow me on social media for latest post updates.