click link selenium web driver works for ie not firefox click link selenium web driver works for ie not firefox selenium selenium

click link selenium web driver works for ie not firefox


As Slanec mentioned these kind of sites use dynamic id's,so a better option in the above specified case would be to use "title" attribute,which has lesser probability of changing..if you want to go with xpath,this will work,

driver.findElement(By.xpath("//*[@title='Mail']")).click();

Even better option will be to use link text,because it works the same way as the user manually would click...

driver.findElement(By.linkText("MAIL")).click();


Selenium has a hard time sometimes with elements embedded within link (<a>) elements. Try your code without the last part of the XPath. So:

//*[@id='pa-u_14782488-bd']/a

Make sure you also post what version of Selenium you are using so others can give you more detailed help.


dont use xpath search.. its highly unstable and doesnt help your case at all. Also your selenium code is now tightly coupled with the markup and any changes to the markup like introduction of a container (i.e div) will fail the test.

you could use scoping to achieve something similar. example:

var container=driver.findElement(By.xpath("//*[@id='pa-u_14782488-bd']"));var spans=container.findElements(By.tagName("span"));spans[1].Click();

Also I dont understand how this works though, cos you have a link and for I am guessing for styling purposes you have two spans within it but clicking on either of them should still trigger the same action as clicking on the click correcT?or am I missing something??

It might just be the case that firefox is handing your events in an incorrect way.