How can I use selenium or appium to automate Chrome browser on Android?

I am trying to automate an Android browser for Android on an Android device (not just in a web browser or in another browser, but in a Chrome browser). I thought it was possible by following this link https://sites.google.com/a/chromium.org/chromedriver/getting-started/getting-started---android , but instead it automates the pc chrome browser.

I also tried Appium, but nothing happens after the log:

debug: executing: adb install C:\Users\hidden\Downloads\AppiumForWindows-0.14.2\ Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk 

And when I try to access information from a browser, I get the following:

 info: Responding to client with error: {"status":13,"value":{"message":"An unkno wn server-side error occurred while processing the command.","origValue":"Did no t successfully proxy server command"},"sessionId":"666c9e4f-7653-487a-b299-959d4 000ca79"} 

I have chromedriver.exe in the PATH environment variable, the whole log looks like this:

 info: Welcome to Appium v0.14.2 info: Appium REST http interface listener started on 127.0.0.1:5555 info - socket.io started debug: Appium request initiated at /wd/hub/session debug: Request received with params: {"desiredCapabilities":{"platform":"ANDROID ","app":"chrome","browserName":"android","browserConnectionEnabled":true,"app-pa ckage":"com.android.chrome","device":"android","rotatable":true,"app-activity":" com.google.android.apps.chrome.Main","takesScreenshot":true,"version":""}} info: Looks like we want chrome on android info: Creating new appium session 666c9e4f-7653-487a-b299-959d4000ca79 info: Ensuring Chromedriver exists debug: Pushing unlock helper app to device... debug: executing: adb install C:\Users\hidden\Downloads\AppiumForWindows-0.14.2\ Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk warn: killed=false, code=1, signal=null debug: Appium request initiated at /wd/hub/status debug: Request received with params: {} debug: Proxying command to 127.0.0.1:9515 info: Making http request with opts: {"url":"http://127.0.0.1:9515/wd/hub/status ","method":"GET"} info: Responding to client with error: {"status":13,"value":{"message":"An unkno wn server-side error occurred while processing the command.","origValue":"Did no t successfully proxy server command"},"sessionId":"666c9e4f-7653-487a-b299-959d4 000ca79"} GET /wd/hub/status 500 1014ms - 238b POST /wd/hub/session 200 31311ms 

Thanks.

+8
android google-chrome selenium appium
source share
4 answers

debug: run: adb install C: \ Users \ hidden \ Downloads \ AppiumForWindows-0.14.2 \ Appium \ node_modules \ appium \ build \ unlock_apk \ unlock_apk-debug.apk

If nothing happens here, you need to restart the ARM emulator and the appium / chromedriver server again. I came across this several times and noticed many times when adb disconnects and loses connectivity. If I restart abd, everything will start working. This is just an adb command to install apk, it will take time depending on the size of apk, but not so much.

 public static void main(String[] args) throws MalformedURLException{ DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("device","Android"); capabilities.setCapability("app", "Chrome"); capabilities.setCapability(CapabilityType.BROWSER_NAME, ""); capabilities.setCapability(CapabilityType.VERSION, "4.3"); capabilities.setCapability(CapabilityType.PLATFORM, "WINDOWS"); WebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); driver.get("http://www.yahoo.com"); } 

I have this piece of code that works well on appium, automating the Chrome Chrome browser. In the above log, the chromatograph does not start successfully, so the browser is not automated. I have an appium log that automates the Chrome browser: enter image description here In addition, any combination of ChromeDriver and the Chrome APK does not work. Since then I have been struggling with this and found out that: Chrome Driver 2.3 and Chrome APK 29.xxx are compatible. Chrome Driver 2.9 / 2.8 and Chrome APK 30.xx or 31.xx do not work.

Relatively simple ChromeDriver: You mentioned the mentioned chrome link to automate the PC browser, if you did not install this feature. Something like that:

 DesiredCapabilities capabilities=new DesiredCapabilities();//DesiredCapabilities.chrome(); ChromeOptions options=new ChromeOptions(); options.setExperimentalOptions("androidPackage", "com.android.chrome"); capabilities.setCapability(ChromeOptions.CAPABILITY, options); 

You need to install this feature if you are just using chromedriver (and not appium). I am working on this but cannot find the opportunity. You will also need to run ChromDriver yourself on the promt command, which will listen on port 9515 for any automation.

+8
source share

1) Read the application logs and see which version of the chrome driver it has in mind. 2) Check online the latest version of chrome plating. To date, the latest version 2.23. Download it for WindowsAnd, extract it http://chromedriver.storage.googleapis.com/index.html?path=2.23/ 3) Update Appium (last today - 1.4.16.1) Now go to this place, C: \ Program Files (x86) \ Appium \ node_modules \ appium \ node_modules \ appium-chromedriver \ chromedriver \ win

And paste the chromedriver.exe file here (replace the old one)

4)

  public AndroidDriver<AndroidElement> startChrome() { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("deviceName", "AndroidDevice"); capabilities.setCapability("newCommandTimeout", 180); capabilities.setCapability("appActivity", "com.google.android.apps.chrome.Main"); try { driver = new AndroidDriver<>(new URL(appiumURL), capabilities); driver.get("google.com") } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return driver; } 

5) In case this does not work, make sure you check the application logs if it points to an updated version of chrome

+1
source share

First, check that your mobile device is connected to the Chrome browser. Enter the following command in the web browser url

 chrome://inspect/devices#devices 

This will show a list of connected devices.

Then set the desired features.

Below is the code for me:

 public void setUp() { File app = new File("./TestingAPK/app-release-v3.1.0-c20170201.apk"); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(CapabilityType.BROWSER_NAME, "Chrome"); capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID); capabilities.setCapability("deviceName", "emulator-5554"); capabilities.setCapability("unicodekeyboard", true); capabilities.setCapability("resetkeyboard", true); capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "21"); capabilities.setCapability("appPackage", "app.mangalam.billboy"); capabilities.setCapability("appActivity", "app.mangalam.billboy.main.SplashActivity"); capabilities.setCapability("app", app.getAbsolutePath()); try { driver = new AndroidDriver < > (new URL("http://127.0.0.1:4723/wd/hub"), capabilities); } catch (MalformedURLException e) { e.printStackTrace(); } driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS); } 
0
source share

I configured this method and it works fine.

  String appium_node = ("http://0.0.0.0:4723/wd/hub"); //Set the Desired Capabilities DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability("deviceName", "Mi Android Phone"); caps.setCapability("udid", "ba689af30404"); //Give Device ID of your mobile phone caps.setCapability("platformName", "Android"); caps.setCapability("platformVersion", "8.1.0"); caps.setCapability("browserName", "Chrome"); caps.setCapability("noReset", true); caps.setCapability("unicodekeyboard", true); caps.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID); try { driver = new AndroidDriver < > (new URL(appium_node), caps); } catch (MalformedURLException e) { e.printStackTrace(); } driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS); } 
0
source share

All Articles