Selenium RC:如何单击使用 onclick window.location 的按钮?
我有一个按钮(表单外部),使用 onclick
属性重定向到另一个页面,该属性调用 window.location
将用户重定向到另一个页面。这次我无法更改 HTML。我正在使用 Safari 4 进行测试。如何单击使用 onclick
属性和 window.location
的按钮以使用 Safari 4 和 Selenium RC PHPUnit 扩展进行重定向?
这是我的 HTML:
<input type="button" onclick="window.location='/registrations/new'" value="Start a new registration" id="create">
更新: 或者,我正在考虑做一些事情,断言在 window.location=''
中指定了一个位置,存储该位置,并使用该位置调用 open()
命令。不确定这是否是可接受的测试方法。
I have a button (outside of a form) that redirects to another page using the onclick
attribute that calls window.location
to redirect the user to another page. This time I can't change the HTML. I am using Safari 4 for testing. How can I click a button that uses the onclick
attribute and window.location
to redirect using Safari 4 and Selenium RC PHPUnit Extension?
Here's my HTML:
<input type="button" onclick="window.location='/registrations/new'" value="Start a new registration" id="create">
Update: Alternatively, I'm thinking about doing something where I assert that a location is specified in the window.location=''
, store that location, and call the open()
command using that location. Not sure if this is an acceptable approach to testing this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们决定扩展默认的
clickAndWait()
功能,以便在按钮具有onclick="window.location='/something';" 时调用
openAndWait()
We decided to extend the default
clickAndWait()
functionality to callopenAndWait()
if the button has anonclick="window.location='/something';"
这应该可以工作,但是您也可以尝试使用
fireEvent
命令触发点击事件。This should work, however you could also try firing the click event using the
fireEvent
command.