Gio*_*olo 5 javascript selenium jasmine angularjs protractor
登录后尝试获取任何元素属性时,量角器完全挂起(idk是与登录有关,还是与切换页面有关)。
it("Should get location of main container", async function() {
await LoginPage.validLogin();
// Works and logs in the dashboard
await browser.sleep(3000);
// Get the main container by class name
const container = await element(by.css(".main-container"));
// Logs properly the element functions (as expected)
console.log(container);
console.log(await container.getLocation()); // Hangs here
});
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我试图获取页面上主容器元素的位置。第一个console.log会启动并正确显示,而第二个则完全挂起,因此我得到了脚本超时。延长超时时间根本没有帮助...
我在网上发现,在AngularJS中误用$ timeout而不是使用$ interval可能会导致这种奇怪的行为,但是我真的无法浏览整个(很大)项目的代码库来更改所有希望它起作用的东西,而不是谈论关于使用$ timeout的外部库。
我有SELENIUM_PROMISE_MANAGER = false; 在我的量角器配置中,因此我禁用了内置控制流,以便使用async / await手动管理promise,但是即使使用内置控制流而不使用async / await,我也会得到完全相同的行为和错误。我正在使用Jasmine作为测试框架。
也许我缺少什么?任何帮助将不胜感激,谢谢!
小智 0
尝试这样的事情:
it("Should get location of main container", async function() {
await LoginPage.validLogin();
const container = await element(by.css(".main-container"));
await browser.wait(protractor.ExpectedConditions.presenceOf(container), 5000, 'Element taking too long to appear in the DOM');
await console.log(await container.getLocation());
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
226 次 |
| 最近记录: |