简体   繁体   English

硒铬驱动程序无此会话

[英]Selenium chrome driver No Such Session

OS: OSX 10.12.2 作业系统:OSX 10.12.2

Selenium Version: 2.52.0 Scrapy 硒版本:2.52.0 Scrapy

Browser: Chrome 浏览器:Chrome

Browser Version: 55.0.2883.95 (64-bit) 浏览器版本:55.0.2883.95(64位)

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. 当我将其与最新的chrome驱动程序一起使用时。 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). 我发现将我的Chrome本地版本降级到53.0.2785.116使得测试可以再次使用Protractor进行。 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. 这不是一个很好的解决方案(因为这是您的本地版本,它将清除您的浏览器历史记录),但是在解决以下详细的错误之前,该解决方案将允许使用Protractor和Chrome进行本地测试。

http://www.slimjet.com/chrome/google-chrome-old-version.php 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 显然,Web驱动程序管理器存在一个已知错误,该错误不允许将其更新为2.24。
https://github.com/angular/webdriver-manager/issues/93 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. 量角器本身具有配置文件,因此请确保所使用的版本具有最高使用2.23版的chromedriver。 I am using protractor 3.1.0 giving me 我正在使用量角器3.1.0给我

  "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). 由于存在此错误,您本地的Chrome版本将远远超出webdriver-manager可以支持或期望的版本(在本例中为创建会话)。

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. 如果将浏览器安装到较旧版本的Chrome,则有必要阻止Google更新,因为每次重新打开浏览器时,Chrome都会尝试移至最新版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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