Hana Bzh
Hana Bzh

Reputation: 2260

window.showModalDialog not appear when running with selenium

In java web application there's a line of code which opens a popup window whenever clicking on a link and this window has ok/cancle button:

return window.showModalDialog("popupWindow", obj, sFeatures);

I use below code in selenium to click on the link

geckoDriver.findElement(By.xpath(".//a[contains(@onclick, 'return openlink(8251')]")).click();

I'm sure the link is clicked successfully but the window.showModalDialog does not open and I can not go on because of that.

What is the problem?

Note that I use gecko driver and I also test my application with chromeDriver and ieDriver with no success

Html tag:

<td width="80" aria-describedby="grdOpeningTrustCartable_" title="openning" style="text-align:center;" role="gridcell">
<a class="gridHighlight" onclick="return openLink(8251,'04/12/17 15:50:00')" href="javascript:void(0);">openning</a>
</td>

Upvotes: 0

Views: 167

Answers (1)

Kushal Bhalaik
Kushal Bhalaik

Reputation: 3384

You can use JavaScript Exceutor to overcome this problem; given that your click is a working but not resulting into any action:

JavascriptExecutor js = (JavascriptExecutor) driver;

js.executeScript("return openLink(8251,'04/12/17 15:50:00');");

Upvotes: 1

Related Questions