Currently utilizing Selenium Webdriver for my testing. The test-case involves:
- Logging in to the site.
- Clicking on the Notifications link.
I am experiencing an issue when attempting to click on the notification link. Here is a snippet of the HTML code causing the problem:
<ul class="rghtSec fr menu logged"><li><a href="javascript:;">
<div class="topIcon notify"><span> </span></div>
<div class="mTxt">Notifications<span id="rJobCntr" class="rJobCntr"></span></div></a>
<div class="subMenu recommendTT">
<ul>
<li><a target="_blank" class="blob" id="blobId" href="http://jobsearch.naukri.com/notifications">
Fetching jobs you may apply for</a></li>
</ul>
I have attempted 5 different methods:
/*1*/ driver.findElement(By.xpath("//a[@class='mTxt']")).click();
/*2*/ driver.findElement(By.cssSelector("div[class='topIcon notify']")).click();
/*3*/ driver.findElement(By.linkText("Notifications")).click();
/*4*/ driver.findElement(By.xpath("//div[@class='pNotifyCont dspN']")).click();
/*5*/ Actions mouse=new Actions(driver);
WebElement element=driver.findElement(By.xpath("//div[@class='pNotifyCont dspN']"));
mouse.moveToElement(element).click().build().perform();
Error :
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"//a[@class='mTxt']"}
Command duration or timeout: 7.56 seconds
Unfortunately, none of these approaches are solving the issue :(, Any assistance on how to resolve this would be greatly appreciated!