我对Selenium非常陌生,我正在尝试让代码点击正确的googleweb搜索链接。如果我添加或删除以下项的s:(driver.find\元素\按\链接\文本)它仍然不起作用,当它起作用时,click()就不起作用了。我只能让两个中的一个起作用,而不是两个都起作用。你知道吗
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Chrome(executable_path='Python\chromedriver.exe')
driver.get('https://www.google.com/')
element = driver.find_element_by_name('q')
element.send_keys('Villanova')
element.send_keys(Keys.ENTER)
element = driver.find_element_by_link_text('Villanova College - King City').click()
time.sleep(5)
driver.close()
DOM中不存在链接文本“维拉诺瓦学院-国王城”。 目前的文本是“维拉诺瓦大学国王城”没有连字符。 另外,您要查找的元素不可见。你知道吗
早期错误:
以下是“维拉诺瓦大学国王城”生成的错误日志:
相关问题 更多 >
编程相关推荐