H.A.
H.A.

Reputation: 161

Selenium locating element - Angular

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?

Upvotes: 0

Views: 3044

Answers (2)

PrinceOFF
PrinceOFF

Reputation: 95

Try this:

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

Upvotes: 0

RNS
RNS

Reputation: 625

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.

Upvotes: 2

Related Questions