Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
246 views
in selenium-and-webdriver by The go-to Tester (181 points)
retagged by
how do you test web application on real mobile device?

1 Answer

0 like 0 dislike
by The go-to Tester (181 points)

Yes, you can certainly execute your tests on mobile devices using selenium webdriver.

You can use Appium(http://appium.io/) server to do that.

You can test web applications as well as native moible applications for Android and iOS both.

 

Setting up desired capabilities:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.1");
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Safari");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");

 

Sample of the web application test:

DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Safari");
URL url = new URL("http://127.0.0.1:4723/wd/hub");
AppiumDriver driver = new AppiumDriver(url, desiredCapabilities);
 
// Navigate to the page and interact with the elements on the guinea-pig page using id.
WebElement div = driver.findElement(By.id("i_am_an_id"));
Assert.assertEquals("I am a div", div.getText()); //check the text retrieved matches expected value
driver.findElement(By.id("comments")).sendKeys("My comment"); //populate the comments field by id.
 
//close the app.
driver.quit();

Sample of the native application test:

Sample APK:

Eg.

wait(for_text("Accessibility")).click();
wait(for_text_exact("Accessibility Node Provider"))
 

Hope that helps


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...