Help with Selenium2Library's "create webdriver" keyword and specifying the remote URL

3,755 views
Skip to first unread message

Pedro Perez

unread,
Mar 10, 2014, 2:01:00 PM3/10/14
to robotframe...@googlegroups.com
Hello,

I'm having trouble using Selenium2Library's "create webDriver" keyword. I'm not able to specify a URL when using the "remote" driver. My keyword looks like this:

*** Keywords ***
open app
    ${capabilities}=    Create Dictionary
    Set To Dictionary    ${capabilities}    app    sauce-storage:app.zip
    Set To Dictionary    ${capabilities}    device    android
    Set To Dictionary    ${capabilities}    version    4.2
    Set To Dictionary    ${capabilities}    deviceType    phone
    Set To Dictionary    ${capabilities}    app-activity    .activity
    Set To Dictionary    ${capabilities}    app-package    com.packagename.app
    Log Dictionary    ${capabilities}
    Create Webdriver    Remote    desired_capabilities=${capabilities}    command_executor=http://remote_url:80/wd/hub

I get this error when running my test:

FAIL : AttributeError: 'unicode' object has no attribute 'execute'

Really I'm looking for a way to be able to pass in arguments to Remote WebDriver's _init_ (which is what I think the create webdriver keyword is supposed to do). I want to pass in the remote URL. I believe that's specified with the command_executor parameter. I'm looking here for Remote Webdriver's init argument documentation: http://selenium.googlecode.com/svn/trunk/docs/api/py/webdriver_remote/selenium.webdriver.remote.webdriver.html.

The end goal is really just to perform some native app testing with Appium on Saucelabs. Appium uses selenium's JSON Wire protocol, so I was hoping Robot Framework's Selenium2Library could consume it as well. However the "open browser" keyword doesn't seem to be able to support this kind of testing, since it can't take the "remote" browser. I can almost get away with using the android browser, but then my test fails since the browser isn't able to start.

I have to believe there is some kind of support for this and I'm just doing it wrong. I feel like I'm close. Has anybody had any success with using the Remote driver and Selenium2Library's create webdriver keyword?

Thanks so much!

Kevin O.

unread,
Mar 10, 2014, 2:54:58 PM3/10/14
to robotframe...@googlegroups.com
I think you are close. When Selenium added Python3 support in 2.32, there was lots of breakage involving unicode strings in Python2. Most of the breakage was fixed, but Remote still has same issue as other parts - the code will work with an str but not a unicode.
Here is the problematic code taken from 2.40:
        if type(self.command_executor) is bytes or type(self.command_executor) is str:
            self.command_executor = RemoteConnection(command_executor, keep_alive=keep_alive)

Try adding:
${executor}=    Evaluate    str('http://remote_url:80/wd/hub')    # create str string instead of unicode string
and then use it:
Create Webdriver    Remote    desired_capabilities=${capabilities}    command_executor=${executor}

You might be able to use Open Browser if you use browser=android and set browserName to ${EMPTY} in your desired capabilities. I do not test on mobile so I cannot confirm. The base capabilities for Android are: 
        "browserName": "android",
        "version": "",
        "platform": "ANDROID",
        "javascriptEnabled": True,

I noticed this issue a while back just by looking at the code but was too busy or lazy to report it. If this works for you, would you consider reporting it the Selenium team so they can fix it?

Good Luck,
Kevin Ormbrek

Pedro Perez

unread,
Mar 10, 2014, 11:43:04 PM3/10/14
to robotframe...@googlegroups.com
That did actually work! Thanks so much for your help. I will see if I can submit an issue with the selenium team.

I still wasn't able to complete a test with Appium, but I think that may be a separate issue--for whatever reason the browser won't start there. However, I was able to submit a remote URL with the evaluate method you described.

Thanks again!!!

Pedro

Senthil sivaramakrishnan

unread,
Feb 27, 2019, 7:16:16 AM2/27/19
to robotframework-users
Hi,
Fix given by Kevin  works perfectly fine, however, I get error as "No application is open" while i try to locate a web element after launching the browser.
Any idea what could possibly make this happen?

Code that I used:

    ${desired_capabilities}=    Create Dictionary
    Set to Dictionary    ${desired_capabilities}    deviceName    ${Device_Name}
    Set to Dictionary    ${desired_capabilities}    platformName    ${Platform_Name}
    Set to Dictionary    ${desired_capabilities}    platformVersion    ${Platform_Version}
    Set to Dictionary    ${desired_capabilities}    deviceOrientation     ${Device_Orientation}
    Set to Dictionary    ${desired_capabilities}    browserName    ${Mobile_Browser_Name}
    Set to Dictionary    ${desired_capabilities}    appiumVersion    ${Appium_Version}
    Set to Dictionary    ${desired_capabilities}    deviceType    ${Devce_Type}
    ${executor}=    Evaluate    str('${Appium_Server}')
    Create Webdriver    Remote    desired_capabilities=${desired_capabilities}    command_executor=${executor}
    Go To    ${Base_URL}
    Input Text    ${L_txt_Login_Username}    ${login_username}
    Input Text    ${L_txt_Login_Password}    ${login_password}
    Click Button    ${L_btn_Login_Signin}

In the above code everything works untill Go To URL statement, Failed in Input Text statement with error "No Application is open"

Below are my system spec:
Appium v1.10
Robot Framework  3.1.1 (Python 2.7.15 on win32)
Chrome driver version: 2.44 and Chrome Browser version: 69.0.3497.0
Reply all
Reply to author
Forward
0 new messages