我试着打开一个浏览器,用python脚本点击一个按钮 我的代码:
from selenium import webdriver
browser = webdriver.Chrome('/usr/local/bin/chromedriver')
browser.get('xxx')
browser.implicitly_wait(5)
button = browser.find_element_by_css_selector('#softGateBox > div.button_softgate > a')
button.click()
网站打开。它等待5秒钟,然后我看到错误:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"#softGateBox > div.button_softgate > a"}
有什么问题吗?我使用chrome来检查按钮,并执行右键单击和单击复制选择器。你知道吗
这个页面没有什么问题
<iframe>
内,因此必须先找到<iframe>
和switch_to_frame()
,然后才能搜索元素<iframe>
在外部<iframe>
中,因此在开始搜索内部<iframe>
之前,首先必须找到外部<iframe>
和switch_to_frame()
是的。你知道吗
顺便说一句:
页面上可以有其他
<iframe>
,所以您不能直接执行selector('iframe')
。你知道吗内部框架有
id
,但每次加载页面时它都会更改,所以不能执行selector('iframe#some_uniqe_id')
相关问题 更多 >
编程相关推荐