This will help to run selenium scripts inside an android mobile web browser
Step-by-step guide
Set-up Android device
- Download the latest android webdriver apk file from HERE (im playing with C#).
- Install downloaded apk file on the android device.(adb install <file name.apk>).
- From the android device locate the the Webdriver application with the selenium logo.
- Tap on the icon to start the selenium server.
- From the host computer/ server open a command prompt and run type adb forward tcp:8080 tcp:8080 .
- Tap on enter key.
If you get any error on above command try to kill all the processors / task listening and started using port 8080.Re run the command.
We use above command to forward the ports and create a link between android device and the host computer/ server
7. To check whether the server woks fine , navigate to web browser and go to below URL.(Using host computer/ server )
If the server works fine (newly created link between android device and the host computer are working file) ,User should see something like below image on the web browser.

8. Click on "Create Session" button and select android as on the below image.

9. Click on OK button.
10. Session should create successfully as on the bellow image.

Set-up Host computer / Server
- Download the latest selenium .net drivers from HERE.
- Open Visual studio and create a new CodedUI project.
- Add all the dll files which are inside the downloaded selenium .net driver archive to the reference folder of newly created CodedUI project as on the below image.
- You may need add OpenQA.Selenium.Android namespace to test class file.
- On the test class create new AndroidDriver instance to initialise the webDriver and start writing test scripts according to the standard way.
eg:
[TestMethod]
public void CodedUITestMethod1()
{
IWebDriver driver = new AndroidDriver();
driver.Navigate().GoToUrl("https:www.google.com");
Assert.AreEqual(driver.Title.ToString(),"Google");
}
No comments:
Post a Comment