Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium - Modal dialog present - how to accept information?

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?

like image 932
Sowiarz Avatar asked Dec 26 '22 04:12

Sowiarz


1 Answers

I found a solution by following code:

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

It works for me.

like image 69
Sowiarz Avatar answered Jan 06 '23 03:01

Sowiarz