1

I'm trying to find an element based on the attributes of multiple children. This is what I have so far

//div[a[contains(text(),"Liquid")] and a[contains(text(),"Orange")]]

This is what I want to find

<div class="inner-article">
    <a style="height:150px;" href="/shop/hats/jjklos2it/cacyn7gr5"
        <img width="150" height="150" src="//assets.supremenewyork.com/158414/vi/iDhLpmX68d4.jpg" alt="Idhlpmx68d4">
        <div class="sold_out_tag">sold out</div>
    </a>
    <h1>
        <a class="name-link" href="/shop/hats/jjklos2it/cacyn7gr5">Liquid Silk Camp Cap</a>
    </h1>
    <p>
        <a class="name-link" href="/shop/hats/jjklos2it/cacyn7gr5">Orange</a>
    </p>
</div>

In conclusion, I want to find the div with both 'Liquid' and 'Orange' children.

1 Answer 1

1

Those links are not children, but descendants, so try

//div[.//a[contains(text(),"Liquid")] and .//a[contains(text(),"Orange")]]
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, how would I make it so the code also specifically chooses the div with the class "inner-article".
@RishiPatel , //div[@class="inner-article" and .//a[contains(text(),"Liquid")] and .//a[contains(text(),"Orange")]]. Don't forget to accept answer if it solved your problem

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.