0

I have to identity an element in the following HTML:

<main-nav-bar _nghost-oyw-6="">
<div class="navigation-bar" _ngcontent-oyw-6="">
<button _ngcontent-oyw-6="">Entities</button>
<button _ngcontent-oyw-6="">Entity settings</button>
<button _ngcontent-oyw-6="">Batches</button>
<button _ngcontent-oyw-6="">Documents</button>
</div>
</main-nav-bar>
</div>

The element I'm interested in is the one containing 'Entity settings'. I think the best way would be css or xpath but so far I haven't been able to identity one that works. My test keeps on failing. Any ideas?

3
  • Share your locators Commented May 12, 2017 at 11:37
  • For example: css = "div.header-bar > main-nav-bar > div.navigation-bar:nth-child(2)" Commented May 12, 2017 at 11:51
  • css = "div.header-bar > main-nav-bar > div.navigation-bar:nth-child(2)" means that you want to match second div, but not button. You can try css = "div.header-bar > main-nav-bar > div.navigation-bar > button:nth-child(2)" or simple xpath = "//button[text()='Entity settings']" Commented May 12, 2017 at 11:59

2 Answers 2

2

To find the element by name of the element you can try following solution :

driver.findElement(By.xpath("//*[contains(text(), 'Entity settings')]"));

Hope it will help you.

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

Comments

0

Try this:

//div[@class='navigation-bar']/button[2]

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.