从 Selenium 运行测试时无法打开网页
当我将脚本作为 Junit 测试用例运行时,浏览器会打开并尝试打开提供的 URL。但是,仅打开网站的页眉和页脚,并显示消息“需要 Cookie 和 Javascript
为了正确浏览本网站,您需要在浏览器上启用 Cookie 和 Javascript。要将您的浏览器设置为支持这些要求,请访问浏览器的帮助菜单以获取相应的说明。”
这会使整个脚本失败,因为不显示 Web 元素。
When i run my scripts as Junit test case, the browser opens up and also tries to open the provided URL. But, only the header and footer of the website is opened with the message "Cookies and Javascript Required
In order to correctly view this website, you will need Cookies and Javascript enabled on your browser. To set your browser to support these requirements, please visit your browser's help menu for the appropriate instructions."
This makes the entire script to fail as the Web elements are not displayed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要提供更多信息:
当您正常访问该网站(即不涉及 Selenium RC)时,是否会发生此行为?
您使用哪种浏览器?
您尝试过其他浏览器吗?您可以通过更改此行中的参数来做到这一点:(
一个有用的技巧是在浏览器参数中放入垃圾,当您运行它时,错误消息会显示所有允许的浏览器字符串。)
您是否尝试过启用 cookie 和 Javascript?然后会发生什么?
如果您不希望正常启用 cookie 和 Javascript 并且您使用的是 FireFox,则可以将 Selenium RC 设置为使用允许这样做的特殊代理(但仅适用于 Selenium 测试)。 参见此处
You need to provide some more information:
Does this behavior happen when you access the site normally i.e. without Selenium RC involved?
Which browser are you using?
Have you tried another browser? You can do that by changing the parameters in this line:
(A useful trick is to put garbage in the browser parameter and when you run it, the error message shows all the allowable browser strings.)
Have you tried to enable cookies and Javascript? What happens then?
If you don't want cookies and Javascript enabled normally and you are using FireFox, you can set Selenium RC up to use a special proxy that does allow this (but only for Selenium tests). See here