Unable to create cookies using android

39 views
Skip to first unread message

Ben White

unread,
Aug 2, 2013, 5:44:59 PM8/2/13
to seleniu...@googlegroups.com
Android Init:
        caps = webdriver.DesiredCapabilities.ANDROID
        caps["acceptSslCerts"] = True
        caps["databaseEnabled"] = True
        caps["locationContextEnabled"] = True
        caps["browserConnectionEnabled"] = True
        caps["nativeEvents"] = True
        caps["takesScreenshot"] = True
        caps["cssSelectorsEnabled"] = True
        browser = webdriver.Remote("http://localhost:8080/wd/hub",caps)
        time.sleep(2)
       
        testID = "Droid"
        action = ActionChains(browser)
        browser.implicitly_wait(30)
Firefox Init:
        browser = webdriver.Firefox()
        testID = "FF"
        action = ActionChains(browser)
        browser.implicitly_wait(30)
The Test:
    browser.get(site)
    browser.add_cookie({"name":"featureToggles","value":'true'})


  • This test works find with the above firefox initialization, but when I try and run the test using the android I get the following exception:


Traceback (most recent call last):
  File "C:\Users\user\git\test-automation\Selenium Webdriver Testing\testflow.py", line 251, in <module>
    runTestSuite(browser)
  File "C:\Users\user\git\test-automation\Selenium Webdriver Testing\testflow.py", line 186, in runTestSuite
    runTest1(browser)
  File "C:\Users\user\git\test-automation\Selenium Webdriver Testing\testflow.py", line 41, in runTest1
    browser.add_cookie({"name":"blarg","value":'true'})
  File "C:\Python27\lib\site-packages\selenium-2.32.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 623, in add_cookie
    self.execute(Command.ADD_COOKIE, {'cookie': cookie_dict})
  File "C:\Python27\lib\site-packages\selenium-2.32.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 165, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium-2.32.0-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 152, in check_response

    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: None ; Stacktrace: Method createCookie threw an error in CookieHandler.java
 
  • I'm running Python 2.7, android driver 2.21 on a Samsung Galaxy SIII running Android 4.1.2
  • I'm not sure if I'm just missing something or if this is an issue with the driver?

Ben White

unread,
Aug 7, 2013, 3:56:53 PM8/7/13
to seleniu...@googlegroups.com
Any ideas on how to fix this? Is more information needed?

Ben White

unread,
Aug 8, 2013, 6:14:07 PM8/8/13
to seleniu...@googlegroups.com
Found the solution:

Despite the fact that the documentation here says that the "secure" key is optional (and it is optional for FireFox), it is not optional for Android. Setting the cookie using:

browser.add_cookie({"name":"featureToggles","value":'true',"secure":False})

Resolved the issue.
Reply all
Reply to author
Forward
0 new messages