selenium

Mobile app automation

Android + Chrome + Python

To be able to run tests Chrome broser should be pre-installed on Android device,

Python + Chrome + Android

To be able to work with web-application on Android device using Selenium below pre-conditions should be met:

Start adb and chromedriver server with below commands from cmd/Terminal:

adb start-server
chromedriver

Note down chromedriver server port number from log that looks like

Starting ChromeDriver 2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3) on port 9515

Connect Android device to computer with USB cable

Below is simple Python code to get Google page:

from selenium import webdriver

capabilities = {
 'chromeOptions': {
   'androidPackage': 'com.android.chrome',
                   }
                }
driver = webdriver.Remote('https://localhost:9515', capabilities) # Specify your port number value 
driver.get('https://google.com')
driver.quit()

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow