Selenium / Python for Android

2,121 views
Skip to first unread message

vit

unread,
Jan 5, 2012, 8:58:18 AM1/5/12
to Selenium Users
Could someone give me or refer to a working instruction how to setup
environment to test Android webapps using Python.
I also would like to have a test example.

Luke Inman-Semerau

unread,
Jan 5, 2012, 12:09:06 PM1/5/12
to seleniu...@googlegroups.com
http://code.google.com/p/selenium/wiki/AndroidDriver

After getting the simulator up and running you create your WebDriver instance in python like this:

from selenium import webdriver

# then do your webdriver stuff....

# special thing you can do only with android -
driver.orientation = 'landscape'  # or 'portrait'



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


bis

unread,
Jan 5, 2012, 12:17:43 PM1/5/12
to seleniu...@googlegroups.com
cant you just do something like

driver = webdriver.Android()

instead of using RC

I dont know for sure but in ruby you just do
driver = Selenium::WebDriver.for :android

Luke Inman-Semerau

unread,
Jan 5, 2012, 12:22:39 PM1/5/12
to seleniu...@googlegroups.com
python webdriver.Android()  does not exist.

All the Java and Ruby Android Driver classes are doing is conveniently wrapping the RemoteDriver object with the url and capabilities filled in.

vit

unread,
Jan 6, 2012, 2:25:56 PM1/6/12
to Selenium Users
> After getting the simulator up and running ....
>
Could you please clarify this. I installed SDK. Should I install or
setup anything else.
When I run

>>> from selenium import webdriver
>>> driver = webdriver.Remote("http://localhost:8080/wd/hub", webdriver.DesiredCapabilities.ANDROID)

I am getting

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\selenium\webdriver\remote
\webdriver.py", line 60, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote
\webdriver.py", line 102, in start_session
'desiredCapabilities': desired_capabilities,
File "C:\Python27\lib\site-packages\selenium\webdriver\remote
\webdriver.py", line 153, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote
\errorhandler.py", line 125, in check_response
raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message:
'<html><head><title>Apache Tomcat/6.0.33 - Error report<.........

I think "http://localhost:8080/wd/hub" is not recognised.

Luke Inman-Semerau

unread,
Jan 6, 2012, 4:34:44 PM1/6/12
to seleniu...@googlegroups.com
Did you follow the instructions on the wiki?
http://code.google.com/p/selenium/wiki/AndroidDriver

Make sure you do ALL the steps up until "Using the Android Test Framework"

vit

unread,
Jan 7, 2012, 11:34:23 AM1/7/12
to Selenium Users
Sorry I put my question to a wrong place.
I am repeating it in the right one.

Luke Inman-Semerau

unread,
Jan 9, 2012, 12:40:21 PM1/9/12
to seleniu...@googlegroups.com

Peter Gale

unread,
Aug 24, 2012, 2:06:29 AM8/24/12
to Selenium Users
I don't do python but there's only a couple to choose from.

Can't you just try both to see which works.

If neither works there's something else going on.


Date: Thu, 23 Aug 2012 20:05:47 -0700
From: markru...@gmail.com
To: seleniu...@googlegroups.com
Subject: Re: [selenium-users] Re: Selenium / Python for Android

A very simple question here relating to Android setup with Selenium for Python

In the Selenium Android Driver docs, it says that the location of the Android SDK must exist in ../android_sdk relative to the directory containing the Selenium repository.

If my directory looks like this (selenium 2.25.0 Python bindings)

/lib
    /selenium
          WebDriver.sln
          setup.py
          wire.py
          (other files)
          /py
                 /selenium
                         selenium.py
                         __init__.py



Where would I put the folder android_sdk?
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/7Tx9AmkqxXAJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Krishnan Mahadevan

unread,
Aug 24, 2012, 2:14:10 AM8/24/12
to seleniu...@googlegroups.com
I have used the java bindings along with the Android SDK and I dont remember having to go through with this requirement of having the android sdk  relative to the directory containing the Selenium repository.  

Infact, for working with AndroidDriver using the Android Simulator, you dont even need the Selenium repository codebase.

All you would need is the below:

Android SDK which can be downloaded and installed to any directory of your choice.
Selenium-android-driver-<seleniumversion>.jar
android-server apk file, which you would install into your simulator after you have setup your simulator.

That should do.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/



For more options, visit https://groups.google.com/groups/opt_out.
 
 

Luke Inman-Semerau

unread,
Aug 24, 2012, 12:38:46 PM8/24/12
to seleniu...@googlegroups.com
Listen to what Krishnan said.

../android_sdk  is only needed if you want to build it from source. The relative path is to trunk/
Reply all
Reply to author
Forward
0 new messages