Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to click Image icon using selenium webdriver

I am trying to click the image icon via xPath but when i run the code the link present on image icon is not opening. could you please help me in resolving this issue.

The Code i used to click the mail icon : To Click the Mail Ico

   driver.findElement(By.xpath("//*[@id='e-switcher-mail-icon']")).click();

Html of the pageHtml of page-part2

like image 902
user1564024 Avatar asked Sep 12 '13 00:09

user1564024


Video Answer


1 Answers

As slanec said more information is required or might be the element is not loaded. If u feel that the element has loaded and still its not happening, using java script is one way to click the image element.

Something like this

WebElement element = driver.findElement (By.xpath ("//*[@id='e-switcher-mail-icon']"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript ("arguments[0].click();" , element);
like image 57
Sriram Avatar answered Oct 03 '22 19:10

Sriram