什么是那些(用Selenium)在页面的onload生成JavaScript警告一个外观图释? [英] What would be a walkaround for JavaScript alerts that are generated in a page's onload() using Selenium?

查看:763
本文介绍了什么是那些(用Selenium)在页面的onload生成JavaScript警告一个外观图释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我自动化使用Selenium RC(C#)一个表单页面。当我点击提交按钮,我得到一个警告记录编辑成功!。此警报框的标题是 页面:// WWW ****** COM说:

I am automating a form page using Selenium RC (C#). After I click 'Submit' button, I get an alert 'Records Edited Successfully!'. The title of this alert box is 'The page at http://www.******.com says:'.

不过,硒没有看到此警报。而我不能工作围绕它

But Selenium doesn't see this alert. And I can't work around it.

下面是我已经试过:

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



结果:我收到以下错误: Selenium.SeleniumException:超时30000ms后

然后我尝试:

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



结果:三个窗口被打开(网站,警惕和额外的窗口)。没有被关闭。我得到以下错误: Selenium.SeleniumException:30000ms后超时

然后我尝试:

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



结果:出现以下错误:无法找到标题窗口在 HTTP页面:// WWW ******融为一体说:。

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

有什么建议?请帮助克服这一障碍。

Any suggestions? Please help to overcome this obstacle.

推荐答案

最后,我已经找到了一个解决办法:

Finally I've found a workaround:

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



祝你一切顺利,大家好!

Wish you all the best, everyone!

这篇关于什么是那些(用Selenium)在页面的onload生成JavaScript警告一个外观图释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆