Selenium - Modal dialog present - how to accept information?

可紊 提交于 2019-12-10 17:38:41

问题


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

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?


回答1:


I found a solution by following code:

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

It works for me.




回答2:


In java:

Alert alert = m_driver.switchTo().alert(); 
alert.accept();


来源:https://stackoverflow.com/questions/25991089/selenium-modal-dialog-present-how-to-accept-information

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!