如何在selenium中通过xpath识别前一个兄弟

-2 python selenium xpath selenium-webdriver

这是使用兄弟姐妹后的代码我无法点击复选框.它出什么问题了?

码:

checkbox1 = driver.find_element_by_xpath("td/nobr/a[text()='192.168.50.120']/../preceding-sibling::td/input[@class='checkbox']")
Run Code Online (Sandbox Code Playgroud)

TD

eLR*_*uLL 5

你没有得到正确的元素,你想要得到td.正确的xpath应该是:

//td[nobr/a[text()='192.168.50.120']]/preceding-sibling::td/input[@class='checkbox']
Run Code Online (Sandbox Code Playgroud)