如何使用Selenium和Python查找对象
因此,我使用了find_element_by_xpath,使用selenium在同一html中使用不同的对象 但是现在我试图在同一个html上找到一个特定的元素,总是复制xpath(chrome>inspect element>copy xpath),我得到了NoSuchElementException错误 对象位于任何iframe之外 以下是我试图访问的对象:如何使用Selenium和Python查找对象,python,selenium,xpath,css-selectors,Python,Selenium,Xpath,Css Selectors,因此,我使用了find_element_by_xpath,使用selenium在同一html中使用不同的对象 但是现在我试图在同一个html上找到一个特定的元素,总是复制xpath(chrome>inspect element>copy xpath),我得到了NoSuchElementException错误 对象位于任何iframe之外 以下是我试图访问的对象: <a class="carb-de-grid-name-link" data-index="1">CapLeads Dat
<a class="carb-de-grid-name-link" data-index="1">CapLeads DataExtension_Copy</a>
我已经试着按住程序,等待页面加载(20秒),什么也没有
欢迎任何输入。要查找文本为CapLeads DataExtension\u Copy的元素,可以使用以下任一解决方案:
- 使用
:链接文本
link_data_extension_2 = driver.find_element_by_link_text("CapLeads DataExtension_Copy")
- 使用
:CSS\u选择器
link_data_extension_2 = driver.find_element_by_css_selector("a.carb-de-grid-name-link")
- 使用
:XPATH
link_data_extension_2 = driver.find_element_by_xpath("//a[@class='carb-de-grid-name-link' and text()='CapLeads DataExtension_Copy']")
link_data_extension_2 = driver.find_element_by_xpath("//a[@class='carb-de-grid-name-link' and text()='CapLeads DataExtension_Copy']")