Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to perform click action on this particular button?

I was asked this question on interview. I need to perform click action on "open" button
which is opposite to "CLR-9194":

enter image description here

I told that with help of index I can perform action on that particular "open" button:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

findElement(By.xpath("//label[2]"))

But he told me that I was wrong.

>Solution :

You need to locate the table row parent element based on the CLR-9194 content and then to find the open button child element of that row.
So, if each table row is td element (it can be tr, I don’t know, you did not share the XML) and the open element is "label" the XPath can be something like this:

"//td[contains(.,'CLR-9194')]//label"

The Selenium code will be correspondingly something like:

findElement(By.xpath("//td[contains(.,'CLR-9194')]//label"))

the XPath above can and should be made more precise. We need to see the XML for that.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading