1

HTML structure:

<g class="bars">
    <rect class="bar selected" x="81" y="79" width="66" height="126">
    <rect class="bar selected" x="169" y="79" width="66" height="126">
    <rect class="bar selected" x="257" y="60" width="66" height="145">
</g>

I need to click in bar selected with attribute x=81. How to do this? Thank you

0

1 Answer 1

2

Find the element by xpath. Example (using python bindings):

element = driver.find_element_by_xpath('//g[@class="bars"]/rect[@x="81"]')
element.click()

There are certainly multiple ways to find that element. For instance, you can get the first rect out of the g tag:

//g[@class="bars"]/rect[1]

Or, you can additionally check the class attribute:

//g[@class="bars"]/rect[@class="bar selected"][1]

Or, you can combine the options I've mentioned and make your own xpath. It really depends on the uniqueness of the element and it's attributes across the page. Difficult to say without seeing the complete HTML source of the page.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.