Selenium webdriver: how to deal with javascript onclick in c #

I am testing a website using the Selenium web driver. My intention is to check the HttpWebResponse, which returns 200. However, the button is a javascript onclick event. I am wondering if anyone has any experience with this situation. Here's the HTML for the button:

<td>
<input id="ctl00_ContentPlaceHolder1_ExportPACEButton" type="submit" tabindex="-1" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ContentPlaceHolder1$ExportPACEButton", "", true, "", "", false, false))" value="Export as PACE File" name="ctl00$ContentPlaceHolder1$ExportPACEButton"/>
</td>
+5
source share
1 answer

Try something like this:

public void JavaScriptClick(IWebElement element)
{
    IJavaScriptExecutor executor = (IJavaScriptExecutor)driver;
    executor.ExecuteScript("arguments[0].click();", element);
}

And the driver is the driver that you used elsewhere.

+4
source

All Articles