Selenium - Modal dialog present - how to accept in

2019-06-27 13:03发布

I have a following problem. After Submit some date on page I have a modal dialog like on the picture:

enter image description here

I want to click "ENTER" to go through that modal but it does not work. I have following code:

driver.FindElement(By.CssSelector("input.submit")).Click();
Actions action = new Actions(driver);
action.SendKeys(OpenQA.Selenium.Keys.Enter);

After click on continue manually test go back to next page. I must go through this modal to continue the test. Any ideas how to solve this problem?

2条回答
相关推荐>>
2楼-- · 2019-06-27 13:11

In java:

Alert alert = m_driver.switchTo().alert(); 
alert.accept();
查看更多
女痞
3楼-- · 2019-06-27 13:32

I found a solution by following code:

IAlert alert = driver.SwitchTo().Alert();
alert.Accept();

It works for me.

查看更多
登录 后发表回答