I am new to Selenium with Java.
As per the requirement I need to access a TAB within my Angular application.
<a _ngcontent-ng-c689374991="" data-val="Dreams" routerlink="/dreams" data-toggle="tab" href="/dreams" role="tab" class="active"><span _ngcontent-ng-c870109355="" class="slanted-text">Dreams</span></a>
Every time I try to locate the TAB, it gives error stating "Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element:"
Tried the following ways using xpath, but unable to achieve the result:-
- Using Full XPath
driver.findElement(By.xpath("/html/body/app-root/app-top-nav/div/div/div/div[2]/div/div[2]/ul/li[5]/a")).click();
- Using XPath
driver.findElement(By.xpath("//*[@id=\"offcanvasExample\"]/div[2]/ul/li[1]/a")).click();
- Using Router Link
driver.findElement(By.xpath("//div[@_ngcontent-ng-c870109355-router-link='/dreams']")).click();
- Using HREF
driver.findElement(By.xpath("//*[contains(text(), 'href=/dreams')]")).click();
Could someone please guide me?