javascript - 在signle测试中处理多个浏览器实例时如何设置ignoreSynchronization
问题描述
我正在尝试在单个测试中处理多个浏览器实例..一旦在一个浏览器实例中完成操作..我的脚本将打开新的浏览器实例并且为了忽略同步我写了一个函数但它不起作用browserInstance.ignoreSynchronization=true
甚至不工作。有人可以帮助我吗?
规格文件
this.Then(/^User tried to open in new browser instance$/,async function(){
browser2=await utility.openNewBrowser(browser);
//this common function is not working
//utility.ignoreSync(browser2);
browser2.ignoreSynchronization=true;
browser2.get("https://facebook.com");
page2=new facebook(browser2);
console.log(await browser2.getTitle()+" title");
browser2.sleep(5000);
});
忽略同步的常用函数
var utility=function(){
this.openNewBrowser=function(browserInstance){
return browserInstance.forkNewDriverInstance();
}
this.ignoreSync=function(browserInstance){
browserInstance.ignoreSynchroniation=true;
}
}
module.exports=new utility();
错误日志
Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
解决方案
我的问题已经通过调用 waitForAngularEnabled 2 times1st 得到解决
第一次应该在浏览器创建时,第二次应该在 URL 加载之后
代码
this.ignoreSync=async function(url){
console.log("entered in to ignore");
browserInit.waitForAngularEnabled(false);
await browserInit.get(url);
browserInit.waitForAngularEnabled(false);
console.log("came out from ignore")
}
这是我的解决方案,如果有人有更好的解决方案,请随时发布。
推荐阅读
- asp.net-core - 来自 ASP.Net Core 中 DistributedSession 的“访问过期会话”异常
- c++ - 获取“浮点异常:8”(我正在使用 Visual Studio Code)
- ruby - “包括?” 方法与作为数组元素和字符串传递的相同字符串的工作方式不同
- wordpress - 客户登录后我的主页重定向次数过多
- excel - 如何在excel中通过类似功能实现分组
- c# - 无法将类型“int”隐式转换为“bool”
- javascript - Angular 应用程序无法识别 StencilJs 自定义 Web 组件的全局样式
- encoding - DBI(数据总线反转)是否保存熵?
- python - 如何解决这个显示正确输出的问题?
- gatsby - 动态引用不在 Gatsby 中的静态目录中的图像