Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.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 如何单击与另一个字符串位于同一行中的链接?_Python_Html_List_Selenium_Automation - Fatal编程技术网

Python 如何单击与另一个字符串位于同一行中的链接?

Python 如何单击与另一个字符串位于同一行中的链接?,python,html,list,selenium,automation,Python,Html,List,Selenium,Automation,我想单击与另一个链接/文本位于同一行的链接。最好的办法是什么 我想点击发票所在行的“编辑”按钮。我将所有发票复制到一个列表中,但我必须从列表中的每个发票中删除“发票”部分 对于列表中的每个发票,我想单击同一行中的“编辑”按钮。该列表处于for循环中,因此我需要程序每次单击发票旁边的Edit(编辑)按钮 谢谢你的帮助 编辑| ViewIDD2CustomerTripe代码事件日期发票发票销售订单发票条款发票类型余额 | 245950 基金 11/14/2019 订单号#0073 关于航运 该

我想单击与另一个链接/文本位于同一行的链接。最好的办法是什么

我想点击发票所在行的“编辑”按钮。我将所有发票复制到一个列表中,但我必须从列表中的每个发票中删除“发票”部分

对于列表中的每个发票,我想单击同一行中的“编辑”按钮。该列表处于for循环中,因此我需要程序每次单击发票旁边的Edit(编辑)按钮

谢谢你的帮助


编辑| ViewIDD2CustomerTripe代码事件日期发票发票销售订单发票条款发票类型余额
| 
245950
基金
11/14/2019
订单号#0073
关于航运
该账户资金不足
476
| 
3831
基金
11/14/2019
订单#0068
关于航运
该账户资金不足
1,027.18
编辑|查看IDID2客户Tripe代码事件日期发票销售订单发票条款发票类型余额

您可以使用
xpath
找到发票中的
,然后从那里转到具有“编辑”功能的同级

invoice = 'INV10'
driver.find_element_by_xpath(f'//td[./a[.="Invoice #{invoice}"]]/preceding-sibling::td/a[.="Edit"]')

使用
。通过xpath查找元素,利用
子体

inv = "INV10"
driver.find_element_by_xpath('//tr[descendant::td[contains(.,"Invoice #' +inv +'")]]//td//a[text()="Edit"]').click()