简体   繁体   English

硒-如何在不关闭硒窗口的情况下更改当前窗口位置?

[英]selenium - how to change current window location without closing the selenium window?

I am using the seleniumIDE 我正在使用seleniumIDE

I want a Test Case to go to another location based on a condition (note: the condition part is why I am using javascript and using the if-then plugin is not an option for now). 我希望测试用例根据条件转到另一个位置(注意:条件部分是为什么我使用JavaScript并暂时不使用if-then插件的原因)。 I have found that even javascript{window.location.replace('http://google.com') } closes my seleniumIDE window and replaces it with google but doesn't affect the actual window where the tests themselves were running. 我发现即使javascript{window.location.replace('http://google.com') }也会关闭我的seleniumIDE窗口,并将其替换为google,但不会影响测试本身正在运行的实际窗口。 I've replaced the condition itself with 1==1 ie true. 我已将条件本身替换为1==1即为true。 to be simple 简单点

Right now I have: 现在我有:

Command  store
Target   javascript{if (1==1) {location="dmstaffing-stage.herokuapp.com/users/sign_out"}}
Value    ignore_me

The problem right now is that this is closing the the seleniumIDE itself and opening a new window. 现在的问题是,这正在关闭seleniumIDE本身并打开一个新窗口。

How can I change the URL location of the window where tests are running 如何更改正在运行测试的窗口的URL位置

Using: 使用方法:

  • this.location.href gave an unexpected Exception this.location.href了意外的异常
  • document.location.href closed my selenium window and then opened a new window and visited the logout page (but original page in original window still logged in) document.location.href关闭我的硒窗口,然后打开一个新窗口并访问了注销页面(但原始窗口中的原始页面仍处于登录状态)
  • location.href also closes my selenium window and open a new window with the logout action location.href还关闭我的硒窗口,并使用注销操作打开一个新窗口

It can be done, but some magic is required. 可以做到,但是需要一些魔术。 Use this.browserbot.openLocation in the target. 在目标中使用this.browserbot.openLocation。 eg this.browserbot.openLocation(' http://blog.reallysimplethoughts.com/ '); 例如this.browserbot.openLocation(' http://blog.reallysimplethoughts.com/ ');

Command  storeEval
Target   this.browserbot.openLocation('http://blog.reallysimplethoughts.com/');
Value    ignore_me

You might want to check out Sel Blocks v1.3.1 and use the if/else around a normal open command. 您可能想签出Sel Blocks v1.3.1并在常规打开命令周围使用if / else。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM