如何连接和重复使用Protractor中已打开的浏览器窗口 [英] How to connect and re-use an already opened browser window in Protractor

查看:200
本文介绍了如何连接和重复使用Protractor中已打开的浏览器窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,量角器脚本在具有以下功能的新浏览器实例中执行

In general, the protractor scripts are executed in a new browser instance with the following capabilities

capabilities: {
'browserName': 'firefox'
}

是否有任何摘要或方法可以对此进行调整;以便我们的脚本通过量角器使用已经打开的浏览器.

Is there any snippets or ways to tweak this; so that our scripts make use of an already opened browser through protractor.

推荐答案

对于 angular2 :

  1. 转到 WebDriverHub 并单击 Create Session ,复制生成的id(例如:2919ed90-efac-48ee-83df-46f8e98ebce7),则在步骤2中将需要它.
  2. 添加/修改protractor.conf.js以反映以下内容.

  1. Go to WebDriverHub and click on Create Session, copy the generated id (eg: 2919ed90-efac-48ee-83df-46f8e98ebce7), you'll need it in step#2.
  2. Add/Modify protractor.conf.js to reflect the following.

exports.config.seleniumAddress:' http://localhost:4444/wd/hub ' , Exports.config.seleniumSessionId:'2919ed90-efac-48ee-83df-46f8e98ebce7', exports.config.directConnect:假

exports.config.seleniumAddress: 'http://localhost:4444/wd/hub', exports.config.seleniumSessionId: '2919ed90-efac-48ee-83df-46f8e98ebce7', exports.config.directConnect: false

观察:

  • directConnect设置为 false 很重要.
  • 每次创建新会话时,都需要更新
  • seleniumSessionId(希望有一种方法可以告诉使用当前运行的浏览器窗口,而无需每次更新seleniumSessionId)
  • Setting directConnect to false is important.
  • seleniumSessionId will need to be updated everytime u create new session (wish there was a way to tell, use current running browser window without updating seleniumSessionId everytime)

这篇关于如何连接和重复使用Protractor中已打开的浏览器窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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