Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.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
使用Selenium、python和Xpath在表行中选择包含特定文本的特定按钮_Python_Selenium_Selenium Webdriver_Xpath_Automated Tests - Fatal编程技术网

使用Selenium、python和Xpath在表行中选择包含特定文本的特定按钮

使用Selenium、python和Xpath在表行中选择包含特定文本的特定按钮,python,selenium,selenium-webdriver,xpath,automated-tests,Python,Selenium,Selenium Webdriver,Xpath,Automated Tests,我试图通过使用XPath单击一行中包含特定文本的按钮 #webdriver.ActionChains(driver)。将_移动到_元素(元素[0])。单击(元素[0])。执行() test=element.find_元素(By.XPATH,'/*[@class=“btn btn sm btn link text success”]”) 打印(测试) webdriver.ActionChains(驱动程序)。将_移动到_元素(测试[0])。单击(测试[0])。执行() 此方法无法正常工作,它可以

我试图通过使用XPath单击一行中包含特定文本的按钮

#webdriver.ActionChains(driver)。将_移动到_元素(元素[0])。单击(元素[0])。执行()
test=element.find_元素(By.XPATH,'/*[@class=“btn btn sm btn link text success”]”)
打印(测试)
webdriver.ActionChains(驱动程序)。将_移动到_元素(测试[0])。单击(测试[0])。执行()
此方法无法正常工作,它可以找到行并单击所需的按钮,但如果我将其做成一个束,它将始终单击第一行中的按钮,而不会单击所需的按钮

这是情况的屏幕截图:

这是表格HTML的代码:

Blue_Coat_basic周三2021年4月14日21-14-36 2021/04/14 21:15:04
使用:

或者,如果此文本位于内部,请使用:

//a[contains(text(),'Blue_Coat')]
不要穿蓝色外套,而是放一条你看到的文字

如果不起作用,请添加更详细的html、链接或将其粘贴到问题中。

而不是
test[0])。单击(test[0])

试试这个

webdriver.ActionChains(driver).move_to_element(test).click(on_element=test).perform()
或者使用
xpath

test = driver.find_element_by_xpath("//tr/td[@class='align-middle pr-1']//a[@class='class='btn btn-sm btn-link text-success']").click()

考虑添加WebSITE已经添加了包含按钮和过滤器名称的HTML代码表,请查看。如前所述,我会按名称选择行,然后单击绿色按钮。问题是当表包含多个元素时。我应该按名称选择合适的行,然后单击按钮。谢谢你的帮助
test = driver.find_element_by_xpath("//tr/td[@class='align-middle pr-1']//a[@class='class='btn btn-sm btn-link text-success']").click()