我正在使用经过身份验证的页面。使用远程webdriver通过executor_url处理经过手动身份验证的Firefox浏览器。 通过新的硒会议,它可以很好地工作;
with Python 2.7.10, geckodriver 0.24.0, Firefox 52.7.1, selenium 3.8.0
>>from selenium import webdriver
>>from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
>>cap = DesiredCapabilities().FIREFOX
>>cap["marionette"] = False
>>driver = webdriver.Firefox(capabilities=cap)
>>driver.execute_script("return myBalance")
[{u'currency': u'USD', u'balance': 0.01}]
但是当我从webdriver处理它时,请重新使用经过身份验证的浏览器;
>>from selenium import webdriver
>>from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
>>cap = DesiredCapabilities().FIREFOX
>>cap["marionette"] = False
>>new_driver = webdriver.Remote(command_executor=executor_url, desired_capabilities=cap)
>>driver.execute_script("return myBalance")
/python/venv/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 208, in check_response
raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: Unrecognized command: POST /session/89792e61-b195-3d45-8fad-8cdffa7b5a44/execute/sync