Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中使用无Id的Selenium或使用XPath单击按钮_Python_Selenium - Fatal编程技术网

在python中使用无Id的Selenium或使用XPath单击按钮

在python中使用无Id的Selenium或使用XPath单击按钮,python,selenium,Python,Selenium,因此,我尝试使用xpath、绝对xpath和类名点击这个编辑按钮,但我没有运气 你试过了吗 //a[starts-with(@href,'/tas/secure/hardware')] 编辑1: 需要进口 from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expect

因此,我尝试使用xpath、绝对xpath和类名点击这个编辑按钮,但我没有运气

你试过了吗

//a[starts-with(@href,'/tas/secure/hardware')]
编辑1: 需要进口

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
代码:

你试过了吗

//a[starts-with(@href,'/tas/secure/hardware')]
编辑1: 需要进口

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
代码:

尝试使用css选择器:

driver.find_element_by_css_selector('a[href^="/tas/secure/hardware"]').click()
或链接文本:

driver.find_element_by_link_text('Edit').click()
尝试使用css选择器:

driver.find_element_by_css_selector('a[href^="/tas/secure/hardware"]').click()
或链接文本:

driver.find_element_by_link_text('Edit').click()

仍然没有运气,我一直得到NoSuchElementException,这个网站是动态的,所以它使一切都变得更加困难。检查更新的答案。如果这不起作用,那么我们可能必须检查元素是否存在于iframe中。我该如何检查它是否在iframe中,也很抱歉,对于selenium和dynamic网站来说还是比较新的。没问题,我们总是在这里。仍然没有运气,我一直得到NoSuchElementException,这个网站是动态的,所以它让一切都变得更加困难。请检查更新的答案。如果这不起作用,那么我们可能必须检查元素是否存在于iframe中。我如何检查它是否在iframe中,也很抱歉,对于selenium和dynamic网站来说,它还是一个新网站。没问题,我们总是在这里。我尝试了这两种方法,但仍然得到一个NosTouchElementException。@RileBunce请尝试添加等等,或者检查它是否在
iframe
标记中?我已经等待了10秒钟,只是为了确保所有东西都有足够的时间加载,并且仍然没有骰子。我尝试了这两种方法,但仍然得到了一个NoTouchElementException。@RileBunce请尝试添加等待,或者检查它是否在
iframe
标记中?我已经等待了10秒钟,只是为了确保所有东西都有足够的时间加载,并且仍然没有骰子。