selenium.common.exceptions.WebDriverException:消息:在python 3.7中

时间:2019-06-24 02:46:21

标签: selenium-webdriver python-3.7

我正在尝试使用硒登录WSJ网站。我停留在单击“登录”的位置。

botton_to_click = WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.ID, "Home")))
botton_to_click.click()

错误消息是:

selenium.common.exceptions.WebDriverException:消息:

在尝试找到By.Xpath之前,它显示了超时错误。所以我将其更改为By.ID 下面是完整的代码。

import time
from bs4 import BeautifulSoup
from bs4.element import Tag
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
base = 'https://www.wsj.com'
url = 'https://www.wsj.com/search/term.html?KEYWORDS=cybersecurity&min-date=2018/04/01&max-date=2019/03/31&isAdvanced=true&daysback=90d&andor=AND&sort=date-desc&source=wsjarticle,wsjpro&page=1'
browser = webdriver.Safari(executable_path='/usr/bin/safaridriver')
browser.get(url)
browser.find_element_by_id('editions-select').click()
browser.find_element_by_id('na,us').click()
botton_to_click = WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.ID, "Home")))
botton_to_click.click()
browser.find_element_by_id('username').send_keys('@#$%#')
browser.find_element_by_id('password').send_keys('@#!$$')
browser.find_element_by_id('basic-login').click()
browser.find_element_by_id('masthead-container').click()
browser.find_element_by_id('searchInput').send_keys('cybersecurity')
browser.find_element_by_name('ADVANCED SEARCH').click()
browser.find_element_by_id('dp1560924131783').send_keys('2018/04/01')
browser.find_element_by_id('dp1560924131784').send_keys('2019/03/31')
browser.find_element_by_id('wsjblogs').click()
browser.find_element_by_id('wsjvideo').click()
browser.find_element_by_id('interactivemedia').click()
browser.find_element_by_id('sitesearch').click()
browser.close()

我不知道如何解决这个问题。我已经尝试了几乎所有东西。

谢谢。

0 个答案:

没有答案