To be able to work with web-application on Android
device using Selenium
below pre-conditions should be met:
Android SDK
installed on computerChrome
browser installed on Android
deviceAndroid
deviceStart 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('http://localhost:9515', capabilities) # Specify your port number value
driver.get('http://google.com')
driver.quit()