问题描述
通常,量角器脚本在具有以下功能的新浏览器实例中执行
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 :
- 转到 WebDriverHub 并单击 Create Session ,复制生成的id(例如:
2919ed90-efac-48ee-83df-46f8e98ebce7
),则在步骤2中将需要它. -
添加/修改
protractor.conf.js
以反映以下内容.
- 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. 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 updatingseleniumSessionId
everytime)
这篇关于如何连接和重复使用Protractor中已打开的浏览器窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!