I am new to Selenium-WebDriver
. Trying to locate an element and click on it.
But constantly getting below error:
unable to locate an element
Firepath
provided following xpath:
"xpath = html/body/header/div/ul/li[2]/a/span[1]"
The relevant HTML code is:
<ul class="nav navbar-nav navbar-right top-nav ">
<li class="identity has-icon">
<a href=".......">
</li>
<li class="settings has-icon">
<a href=".......">
<span class="icon icon-cogs" aria-hidden="true" role="presentation"/>
**<span class="nav-title">Settings</span>**
</a>
</li>
I have tried to find the element in following ways:
1. driver.findElement(By.xpath("//div[@id='right-nav']//a[contains(text(),'Settings')]")).click();
2. driver.findElement(By.xpath("//div[@id='nav-title']//a[contains(text(),'Settings')]")).click();
3. driver.findElement(By.xpath("//div[contains(@class, 'nav-title')]")).click();
Could someone help me find a solution?