量角器-加载主页后无法定位元素
Protractor- Unable to locate element after loading the homepage
登录后无法在主页上找到任何元素。
场景:点击个人资料 name/icon 并点击注销按钮
it('Signout', function() {
//tried with following code
//browser.waitForAngularEnabled(true);
//locator below
//var profileIcon=element(by.model('user'));
common.btnClk(homepage.profileIcon);
common.btnClk(homepage.FCS_signoutbtn);
browser.close();
});
解决方法:
当首页刷新时browser.refresh();然后只能找到元素。
请提出没有此解决方法的解决方案。
日志:
[31m- [39m[31mFailed: Timed out waiting for asynchronous Angular tasks to finish after 120 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular
While waiting for element with locator - Locator: by.model("user").
The following tasks were pending:
- $timeout: function (){$rootScope.authenticated=false;$cookies.remove("access_token");$cookies.remove("organizationId");$cookies.remove("authenticated");$cookies.remove("user_infos");$cookies.remove("user_profile_infos");$cookies.remove("user_depts");ChatSocket.disconnect();$state.go('core.login',{},{reload:true});$rootScope.options={position:'toast-top-right',type:'error',iconClass:{name:'error'},timeout:'5000',extendedTimeout:'1000',html:false,closeButton:true,tapToDismiss:true,closeHtml:'<i class="fa fa-times"></i>'};var msg="Your Token is Expired!";$rootScope.openToast("Session Timeout",msg);}[39m
Executed 2 of 2 specs[31m (1 FAILED)[39m in 2 mins 55 secs.
[12:57:53] I/launcher - 0 instance(s) of WebDriver still running
[12:57:53] I/launcher - chrome #01 failed 1 test(s)
[12:57:53] I/launcher - overall: 1 failed spec(s)
[12:57:53] E/launcher - Process exited with error code 1
附加信息:尝试 browser.ignoreSynchronization = true; & 通过 xpath 定位,它的工作。但我想用 angular 方法进行测试。
** 网站是 angular 站点 **
试过:
browser.driver.manage().window().setSize(1280, 1024);
browser.ignoreSynchronization = 假;
所有脚本超时:160000,
默认超时间隔:160000
请提出任何解决方案。
您的页面上似乎有一个 $timeout
待处理。
由于刷新某种程度上解决了它,该行为背后可能存在与 login/authentication 和页面更改相关的错误(一种时间问题,可能会使以前的承诺未解决)。
如果是这种情况,可能 ControlFlow 需要 "emptied" 作为最后一个操作,在新页面加载之前。也许您的开发人员可以提供帮助。
作为解决方法,请尝试
browser.waitForAngularEnabled(false); //could empty Protractors/Seleniums ChangeDetection on the ControlFlow
browser.waitForAngularEnabled(true); //will observe the ControlFlow for new promises again.
不过,这是一个远景,我耐心地猜测,你可能想试一试。
登录后无法在主页上找到任何元素。
场景:点击个人资料 name/icon 并点击注销按钮
it('Signout', function() {
//tried with following code
//browser.waitForAngularEnabled(true);
//locator below
//var profileIcon=element(by.model('user'));
common.btnClk(homepage.profileIcon);
common.btnClk(homepage.FCS_signoutbtn);
browser.close();
});
解决方法: 当首页刷新时browser.refresh();然后只能找到元素。 请提出没有此解决方法的解决方案。
日志:
[31m- [39m[31mFailed: Timed out waiting for asynchronous Angular tasks to finish after 120 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular
While waiting for element with locator - Locator: by.model("user").
The following tasks were pending:
- $timeout: function (){$rootScope.authenticated=false;$cookies.remove("access_token");$cookies.remove("organizationId");$cookies.remove("authenticated");$cookies.remove("user_infos");$cookies.remove("user_profile_infos");$cookies.remove("user_depts");ChatSocket.disconnect();$state.go('core.login',{},{reload:true});$rootScope.options={position:'toast-top-right',type:'error',iconClass:{name:'error'},timeout:'5000',extendedTimeout:'1000',html:false,closeButton:true,tapToDismiss:true,closeHtml:'<i class="fa fa-times"></i>'};var msg="Your Token is Expired!";$rootScope.openToast("Session Timeout",msg);}[39m
Executed 2 of 2 specs[31m (1 FAILED)[39m in 2 mins 55 secs.
[12:57:53] I/launcher - 0 instance(s) of WebDriver still running
[12:57:53] I/launcher - chrome #01 failed 1 test(s)
[12:57:53] I/launcher - overall: 1 failed spec(s)
[12:57:53] E/launcher - Process exited with error code 1
附加信息:尝试 browser.ignoreSynchronization = true; & 通过 xpath 定位,它的工作。但我想用 angular 方法进行测试。 ** 网站是 angular 站点 ** 试过: browser.driver.manage().window().setSize(1280, 1024); browser.ignoreSynchronization = 假; 所有脚本超时:160000, 默认超时间隔:160000
请提出任何解决方案。
您的页面上似乎有一个 $timeout
待处理。
由于刷新某种程度上解决了它,该行为背后可能存在与 login/authentication 和页面更改相关的错误(一种时间问题,可能会使以前的承诺未解决)。
如果是这种情况,可能 ControlFlow 需要 "emptied" 作为最后一个操作,在新页面加载之前。也许您的开发人员可以提供帮助。
作为解决方法,请尝试
browser.waitForAngularEnabled(false); //could empty Protractors/Seleniums ChangeDetection on the ControlFlow
browser.waitForAngularEnabled(true); //will observe the ControlFlow for new promises again.
不过,这是一个远景,我耐心地猜测,你可能想试一试。