What would be for the JavaScript alerts that are generated on the onload () page using Selenium?

I can automate the form page using Selenium RC (C #). After clicking the "Send" button, I get a warning " Records Edited Successfully!". The title of this alert window is " ".The page at http://www.******.com says:

But Selenium does not see this warning. And I can't get around this.

Here is what I tried:

selenium.Click("ctl00_Content_ctl00_btnSubmit");
selenium.WaitForPageToLoad("30000");

Result: I get the following error: " Selenium.SeleniumException : Timed out after 30000ms"

Then I tried:

selenium.Click("ctl00_Content_ctl00_btnSubmit");
selenium.OpenWindow("", "The page at The page at http://www.******.com says:");
selenium.Close();
selenium.WaitForPageToLoad("30000");

Result: three windows open (site, warning, and additional window). Nothing is closing. I get the following error: " Selenium.SeleniumException : Timed out after 30000ms"

Then I tried:

selenium.Click("ctl00_Content_ctl00_btnSubmit");
selenium.SelectWindow("The page at The page at http://www.******.com says:");
selenium.Close();
selenium.WaitForPageToLoad("30000");

Result: I get the following error: " "Could not find window with title 'The page at http://www.******.com says:'

Any suggestions? Help overcome this obstacle.

+3
3

, :

    selenium.Click("ctl00_Content_ctl00_btnSubmit");                        
    Thread.Sleep(5000);
    selenium.KeyDownNative("32");
    selenium.KeyUpNative("32");

, !

+1

-, - script, alert() , .

((JavascriptExecutor) fDriver).executeScript(
  "window.alert = function(msg) { return true; }"
); 
+4

Source: https://habr.com/ru/post/1775530/


All Articles