I am using Selenium to automate a website interaction through ChromeDriver and .NET C#. The website contains a bootstrap modal dialog as seen in the screen shot. Clicking on the company name in each row will download the company profile PDF document (a child browser window will open for the download).
Human interaction with the website works perfectly. Also, if I run $("div.modal-dialog table>tbody>tr>td")[2].firstElementChild.click(); in Chrome's dev tool console, it also downloads the PDF properly.
But running this line of code in Selenium like this (IJavaScriptExecutor)driver).ExecuteScript(@"$(""div.modal-dialog table>tbody>tr>td"")[2].firstElementChild.click();"); will cause the modal dialog to disappear immediately and no PDF is downloaded.
Selenium is able to find the element at $("div.modal-dialog table>tbody>tr>td")[2].firstElementChild, which I tested in the code, so I'm pretty sure.
I think the automation process is clicking in the main window, not on the modal dialog, causing the latter to disappear immediately. But how to switch to a bootstrap modal popup in Selenium?
Or is it some other problem? Any thoughts? This issue is driving me nuts. Thank you very much in advance.