Raghuvaran
Raghuvaran

Reputation: 1

How to click a image button in selenium

I want to click an image button on the below link. https://www.nseindia.com/products/content/equities/equities/archieve_eq.htm The button name is "Get Data". I tried to click the button using selenium in many ways but I could not

WebElement buttonClick = driver.findElement(By.className("getdata-button")); 
buttonClick.click(); 

Upvotes: 0

Views: 1332

Answers (2)

Jignesh
Jignesh

Reputation: 31

I have tried below Code and it worked well for me

driver.findElement(By.xpath(".//*[@id='wrapper_btm']/div[1]//input[3]")).click();

Apply above code or else provide me Exception Message that you are facing.

Upvotes: 1

Ayush Goel
Ayush Goel

Reputation: 54

You can use javascript executor to directly call the function that is associated with the 'Get Data' button click. Here function 'validateInput()' is called on button click event. Refer below:

driver.get("https://www.nseindia.com/products/content/equities/equities/archieve_eq.htm");
JavascriptExecutor scrExecutor = (JavascriptExecutor)driver;
scrExecutor.executeScript("validateInput()");

This will simulate the click on this button.

Upvotes: 0

Related Questions