can you test on mobile devices using selenium webdriver?

by (171 points)
0 votes
how do you test web application on real mobile device?

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

answered by (171 points)
0 votes

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("");
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.

Sample of the native application test:

Sample APK:


wait(for_text_exact("Accessibility Node Provider"))

Hope that helps