-
-
Save dariodiaz/2500798 to your computer and use it in GitHub Desktop.
selenium: How to Dynamically Add Android Support to Selenium Server at Runtime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to Dynamically Add Android Support to Selenium Server at Runtime | |
---------------------------------------------------------------------------------- | |
1) Launch Selenium Server: | |
---------------------------------------------------------------------------------- | |
# In a terminal window, run this command: | |
$ java -jar selenium-server-standalone-2.21.0.jar | |
Apr 25, 2012 3:53:39 PM org.openqa.grid.selenium.GridLauncher main | |
INFO: Launching a standalone server | |
15:53:44.584 INFO - Java: Apple Inc. 20.6-b01-415 | |
15:53:44.587 INFO - OS: Mac OS X 10.7.3 x86_64 | |
15:53:44.610 INFO - v2.21.0, with Core v2.21.0. Built from revision 16552 | |
15:53:44.861 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub | |
15:53:44.863 INFO - Version Jetty/5.1.x | |
15:53:44.865 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver] | |
15:53:44.867 INFO - Started HttpContext[/selenium-server,/selenium-server] | |
15:53:44.867 INFO - Started HttpContext[/,/] | |
15:53:45.122 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@3ce95a56 | |
15:53:45.125 INFO - Started HttpContext[/wd,/wd] | |
15:53:45.142 INFO - Started SocketListener on 0.0.0.0:4444 | |
15:53:45.142 INFO - Started org.openqa.jetty.jetty.Server@6b0a2d64 | |
---------------------------------------------------------------------------------- | |
2) POST New Browser Info | |
---------------------------------------------------------------------------------- | |
# In a 2nd terminal window, run this command: | |
$ curl -X POST http://localhost:4444/wd/hub/config/drivers -H 'Content-Type: application/json' -d '{"class": "org.openqa.selenium.android.AndroidDriver", "capabilities": {"platform": "ANDROID", "browserName": "android", "version": "", "javascriptEnabled": true}}' | |
---------------------------------------------------------------------------------- | |
3) Check Results (Part I) | |
---------------------------------------------------------------------------------- | |
# You should see this in Selenium Server's console output in terminal window #1: | |
15:53:56.452 INFO - Executing: org.openqa.selenium.remote.server.handler.AddConfig@61acfa31 at URL: /config/drivers) | |
15:53:56.490 INFO - Done: /config/drivers | |
---------------------------------------------------------------------------------- | |
4) Check Results (Part II) | |
---------------------------------------------------------------------------------- | |
# You'll need: | |
# An Android emulator up and running and listening on localhost:8080 | |
# http://code.google.com/p/selenium/wiki/AndroidDriver#Install_the_Android_SDK | |
# | |
# The Python bindings for Selenium | |
# http://readthedocs.org/docs/selenium-python/en/latest/installation.html | |
# In a terminal window, run this command: | |
$ python | |
Python 2.7.1 (r271:86882M, Nov 30 2010, 09:39:13) | |
[GCC 4.0.1 (Apple Inc. build 5494)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> from selenium import webdriver | |
>>> from selenium.webdriver import DesiredCapabilities | |
>>> driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.ANDROID) | |
>>> driver.get('http://google.com') | |
>>> driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment