I am pretty much new to selenium. I have referred previous posts and found out how to click an element using javaScriptExecutor. But unfortunately, it is not working and i can;t where I am going wrong. Below is the code snippet and some screenshots:
This is how i found out the Xpath in chrome:
Code :
@Test
public void Search(){
try{
WebElement element = driver.findElement(By.xpath("//a[contains(@href,\"javascript:__doPostBack('lbSearch','')\")]"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click()", element);
}
catch(Exception e){
System.out.println("Search element not found."+ e.getStackTrace());
}
Thankx in advance!