python , Selenium ,chromedriver 'selenium.common.exceptions.WebDriverException: Message: u' chrome 无法访问

标签 python selenium selenium-chromedriver

我正在使用此代码导航网页,使用 selenium 和 chromedriver 2.9(也尝试过 2.8 但未成功)...我收到此错误,我想要的只是测试以显示在 firefox iframe 中:)

Firefox 支持 iframe 中的图像链接没有问题,而且图像弹出效果很好。但文本不会显示在 iframe 中。不确定为什么图像链接有效,但文本无效。

import os
import platform as _platform
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

def pickbrowser(browserchoice):
    usrplatform = _platform.system()
    if browserchoice == "1":
        browser = webdriver.Firefox()

    elif browserchoice == "2":
        if usrplatform == "Linux":
            chromepath = os.path.abspath("Webdriver/Linux/86/chromedriver")
            os.environ["webdriver.chrome.driver"] = chromepath
            browser = webdriver.Chrome(chromepath)

        elif usrplatform == "Windows":
            chromepath = os.path.abspath("Webdriver/Windows/86/chromedriver.exe")
            print "checkpoint chrome, windows 1"
            os.environ["webdriver.chrome.driver"] = chromepath
            print "checkpoint chrome, windows 2"
            browser = webdriver.Chrome(chromepath)

        elif usrplatform == "darwin":
            chromepath = os.path.abspath("Webdriver/Mac/86/chromedriver")
            os.environ["webdriver.chrome.driver"] = chromepath
            browser = webdriver.Chrome(chromepath)

    elif browserchoice == "3":
        if usrplatform == "Linux":
            browser = webdriver.PhantomJS(os.path.abspath("Webdriver/Linux/86/phantomjs"))

        elif usrplatform == "Windows":
            browser = webdriver.PhantomJS(os.path.abspath("Webdriver/Windows/86/phantomjs.exe"))

        elif usrplatform == "darwin":
            browser = webdriver.PhantomJS(os.path.abspath("Webdriver/Mac/86/phantomjs"))

    elif browserchoice == "4":
        if usrplatform == "Windows":
            browser = webdriver.Ie(os.path.abspath("Webdriver/Windows/86/IEDriverServer.exe"))
    return browser

driver = pickbrowser(raw_input("which browser do you want to use\n 1. Firefox\n 2. Chrome\n 3. PhantomJS\n 4. Internet Explorer\nYour choice: "))
print "\ncheckpoint 1"
driver.get("https://www.chess.com/login")
print "checkpoint 2\n"

WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "btnLogin")))
driver.find_element_by_name("c1").send_keys(raw_input("Username: "))
print "\ncheckpoint 2.1\n"
driver.find_element_by_name("loginpassword").send_keys(raw_input("Password: : "))
print "\ncheckpoint 2.2"
driver.find_element_by_id("btnLogin").click()
print "checkpoint 3\n"

driver.get(raw_input("Link to receivers send pm page: "))
print "\ncheckpoint 4\n"

WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "c15")))
driver.find_element_by_name("c15").send_keys(raw_input("Subject line: "))
print "\ncheckpoint 5\n"

driver.switch_to_frame("tinymcewindow_ifr")
print "checkpoint 5.1"
driver.find_element_by_id("tinymce").clear()
print "checkpoint 5.2"
driver.switch_to_default_content()
print "checkpoint 6"

driver.switch_to_frame("tinymcewindow_ifr")
print "checkpoint 6.1\n"
driver.find_element_by_id("tinymce").send_keys(raw_input("Message: "))
print "\ncheckpoint 6.2"
driver.switch_to_default_content()
print "checkpoint 7"

driver.find_element_by_id("c16").click()

这是从 python 脚本生成的错误消息。该脚本试图通过检查点,但随后会产生错误。我完全迷路了。

checkpoint chrome, windows 1

checkpoint chrome, windows 2

[2888:5992:0213/160704:ERROR:chrome_views_delegate.cc(176)] NOT IMPLEMENTED

[2888:5992:0213/160704:ERROR:desktop_root_window_host_win.cc(746)] NOT IMPLEMENT

ED

[2888:5992:0213/160704:ERROR:desktop_root_window_host_win.cc(746)] NOT IMPLEMENT

ED



checkpoint 1

checkpoint 2



Username: [5268:4808:0213/160720:ERROR:ipc_channel_win.cc(132)] pipe error: 109





checkpoint 2.1



Password: : [2888:5992:0213/160734:ERROR:desktop_root_window_host_win.cc(746)] N

OT IMPLEMENTED





checkpoint 2.2

checkpoint 3



Link to receivers send pm page: 

80

Traceback (most recent call last):

  File "/home/user/Dropbox/Python/chess.com/BFDtest.py", line 60, in <module>

  File "C:\Users\Derek\Dropbox\RK Resource 001\selenium\webdriver\remote\webdriv

er.py", line 176, in get

    self.execute(Command.GET, {'url': url})

  File "C:\Users\Derek\Dropbox\RK Resource 001\selenium\webdriver\remote\webdriv

er.py", line 164, in execute

    self.error_handler.check_response(response)

  File "C:\Users\Derek\Dropbox\RK Resource 001\selenium\webdriver\remote\errorha

ndler.py", line 164, in check_response

    raise exception_class(message, screen, stacktrace)

selenium.common.exceptions.WebDriverException: Message: u'chrome not reachable

  (Session info: chrome=32.0.1700.107)
 (Driver info: chromedriver=2.9.248315,

platform=Windows NT 6.1 SP1 x86_64)'

最佳答案

我从你的代码中注意到你正在操纵 TinyMCE .此编辑器需要由 JavaScript 处理。 SO 和 Internet 上有很多关于如何处理这个问题的答案。这是一个很好的答案:Selenium and wordpress: New post test

关于 python , Selenium ,chromedriver 'selenium.common.exceptions.WebDriverException: Message: u' chrome 无法访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21802784/

相关文章:

php - PHP、Python、PostgreSQL 设计是否适合业务应用程序?

python - 为什么 Enthought Canopy 推出没有样式 css 的 iPython Notebook html 文本?

python - Mac 上支持 Python 2.x 的 Vim 编译

python - 使用 pandas 计算列中的热门值

java - Selenium + gradle + testng,driver.quit()上出现UnsatisfiedLinkError

java - 如何为 Selenium Java FirefoxDriver 设置环境变量?

java - 新的 ChromeOptions()` is preferred to ` DesiredCapabilities.chrome()

java - Selenium WebDriver session

python - 收到元素不可交互或元素不可见的错误

python - Selenium Webdriver 未单击 Href 链接