简体   繁体   中英

Selenium chrome driver No Such Session

OS: OSX 10.12.2

Selenium Version: 2.52.0 Scrapy

Browser: Chrome

Browser Version: 55.0.2883.95 (64-bit)

Hi,

I'm trying to use selenium on my project. But I'm getting No such session error. when I use it with latest chrome driver. Also You can find error below.

Traceback (most recent call last):
  File "/Users/user/Library/Python/2.7/lib/python/site-packages/twisted/internet/defer.py", line 651, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "/Users/user/Downloads/Test-2/ecommerce_bot/ecommerce_bot/spiders/hepsiburada.py", line 67, in parseProductComments
    self.browser.get(response.url)
  File "/Users/user/Library/Python/2.7/lib/python/site-packages/selenium/webdriver/remote/webdriver.py", line 248, in get
    self.execute(Command.GET, {'url': url})
  File "/Users/user/Library/Python/2.7/lib/python/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/Users/user/Library/Python/2.7/lib/python/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
WebDriverException: Message: no such session
  (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Mac OS X 10.12.2 x86_64)

Also This my code.

self.browser.get("url")
xpath = self.browser.find_element_by_xpath("/html/head/script[17]")

And Browser

 def __init__(self):
        super(HepsiburadaSpider, self).__init__()
        chromedriver = "/Users/user/Downloads/chromedriver"
        os.environ["webdriver.chrome.driver"] = chromedriver
        self.browser = webdriver.Chrome(chromedriver)

This was happening to me. I found that downgrading my local version of Chrome to 53.0.2785.116 enabled testing to happen with Protractor (again). This is independent of the version specified in standalone.

Not a great solution (as this is your local version and it will wipe your browser history), but until the bug detailed below is addressed, the one that will allow local testing with Protractor and Chrome.

http://www.slimjet.com/chrome/google-chrome-old-version.php

Apparently there is a know bug with web driver-manager that does not allow it to be updated to 2.24
https://github.com/angular/webdriver-manager/issues/93

Protractor itself has a config file so make sure the version you are using has chromedriver using version 2.23 at the very highest. I am using protractor 3.1.0 giving me

  "webdriverVersions": {
    "selenium": "2.53.1",
    "chromedriver": "2.23",
    "iedriver": "2.51.0"
  } 

Because of this bug your local Chrome version will be too far ahead of what the webdriver-manager can support or is expecting (in this case creating a session).

If the browser is brought to an older version of Chrome it will be necessary to prevent Google updates as Chrome will attempt to move to the most current version every time the browser is reopened.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM