【发布时间】:2019-02-12 23:33:57
【问题描述】:
我执行了:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
import time
print("Opening...")
driver = webdriver.Chrome()
driver.get('https://google.com')
driver.execute_script("window.open('https://www.yahoo.com');") #New tab
search = driver.find_element_by_xpath("//input[@type='text' and @id='uh-search-box']")
search.send_keys('Hello')
给我错误:
selenium.common.exceptions.NoSuchElementException:消息:没有这样的 元素:无法定位元素: {"method":"xpath","selector":"//input[@type='text' and @i d='uh-search-box']"}
这个错误是因为它没有在chrome中完成加载并执行进一步的代码......
如何摆脱它?
如何等待加载并执行进一步的脚本...(就像第一个标签一样,google.com)?
【问题讨论】:
标签: python python-3.x selenium selenium-webdriver selenium-chromedriver