lundi 10 mai 2021

Find the check box and click using selenium webdriver

I need to select the right checkbox in a table with a list of check boxes, the only info I have to find the right row in the table where the right check box is, is in the second column of the table (PO). The first column is the check box and the second is the PO, through this command I click on the PO, but I need to click on the checkbox right before it

XPath = "//*[contains(@href,'" & PO & "')]"

bot.FindElementByXPath(XPath).Click

this is the outer html to find the PO "a href="/bp/po?poId=65NKTERB&tabId=summary">65NKTERB</a" in that xpath

The XPath to the PO is //*[@id="root"]/div/div[2]/div/div/div[2]/div/div[1]/div/div/div/div/div/div/div[2]/div/div/div[2]/div[3]/div[2]/div/div/span/a

And this is the XPath to the checkbox

//*[@id="root"]/div/div[2]/div/div/div[2]/div/div[1]/div/div/div/div/div/div/div[2]/div/div/div[2]/div[3]/div[1]/div/div/span/div/input

The problem is that I don't know in which position the right PO will be. A code to a similar web found the checkbox using this code, but it does not work for me

XPath = "//*[contains(@href,'" & PO & "')]//following::input[1]"

bot.FindElementByXPath(XPath).Click




Aucun commentaire:

Enregistrer un commentaire