How to test chrome in mobile devices without appium:

You can run chrome in android device straight from selenium:

https://chromedriver.chromium.org/getting-started/getting-started—android

First Connect actual device or emulator:

To start emulator follow the below article about installing android-studio:

https://praveendavidmathew.medium.com/android-studio-7174c43708f6

To connect an actual mobile instead then use below article, read about enabling debugger mode:

https://praveendavidmathew.medium.com/android-studio-7174c43708f6

Second make sure you have latest adb version is installed:

download latest from :

https://developer.android.com/studio/releases/platform-tools

the adb will be inside the platform tool folder

Now make sure device is detected and authorized: (these steps are explained in the above mentioned articles)

open the folder in which abd is there and run the below command ./adb

./adb devices

And make sure device shows in the list

make sure it is showing device and not unauthorized:

Now you can run below code:

Here we are using experimental_option “androidPackage” to connect to chrome in mobile device

you can add experimental option (for any binding )

Python:

options = webdriver.ChromeOptions()
options.add_experimental_option('androidPackage', 'com.android.chrome')
driver = webdriver.Chrome('./chromedriver', options=options)
driver.get('https://google.com')
driver.quit()

Java:

System.setProperty(“webdriver.chrome.driver”,””);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption(“androidPackage”, “com.android.chrome”);
WebDriver driver = new ChromeDriver(options);
driver.get(“https://www.google.com");

You can see how to inspect from desktop here:

https://praveendavidmathew.medium.com/android-studio-7174c43708f6

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.