angularjs - 量角器AngularJs,改变位置
问题描述
当我告诉量角器单击更改 currentLocation 的按钮时,正在查看的 html 量角器未更新。
我知道,有 'browser.setLocation()' 方法,它可以很好地达到它的目的。但是,如果按钮在数据库中创建发票,然后更改位置.. 我不能只使用 browser.setLocation,我必须单击按钮并等待新的页面内容,但我无法使用量角器..
编辑:我也试过这个:
var EC = protractor.ExpectedConditions;
return browser.wait(EC.urlContains('invoice'), 2000, "error");
这是行不通的
有解决办法吗?
编辑:这是我的测试代码:
var EC = protractor.ExpectedConditions;
browser.wait(EC.elementToBeClickable($('#menu-newClient')), 2000, "error waiting menu-newClient")
.then(function () {
// Click on 'new client' button, that create a client and change location to client form
return element(by.id('menu-newClient')).click();
})
.then(function(){
// The textbox 'test1' is in the header and works correctly
element(by.model('test1')).sendKeys("test1");
// The textbox 'test2' is in the Client form and protractor don't find it
var el = element(by.className('test2'));
return browser.wait(EC.presenceOf(el), 2000, "error waiting test2")
})
.then(function () {
element(by.model('test2')).sendKeys("test2");
});
第二次测试:
var EC = protractor.ExpectedConditions;
browser.wait(EC.elementToBeClickable($('#menu-newClient')), 2000, "error waiting menu-newClient")
.then(function () {
return element(by.id('menu-newClient')).click();
})
.then(function(){
// Set new location and load the new html
browser.setLocation("client");
})
.then(function(){
// Now protractor find the textbox 'test2'
var el = element(by.className('test2'));
return browser.wait(EC.presenceOf(el), 2000, "error3")
})
.then(function () {
element(by.model('test2')).sendKeys("test2");
});
解决方案
在相同的情况下,下面的代码对我有用:-
browser.wait(function() {
return browser.getCurrentUrl().then(function (url) {
return url.includes("invoice");
});
}, 2000, "Error").then(function() {
//next code will go here
})
推荐阅读
- javascript - 如何使用 CSS 仅将颜色应用于 SVG 图标的一部分?
- android - 小型 Kotlin 演示 ACCESS_FINE_LOCATION
- docker - 是否可以从 dockerfile 将主机路径或 docker 卷挂载到映像中的路径?
- google-bigquery - 如何更改 BigQuery 中列的数据类型
- machine-learning - 层 conv1d_2 的输入 0 与层不兼容::预期 min_ndim=3,发现 ndim=2。收到的完整形状:(无,128)。开发 LSTM-CNN
- python - 如何安装 OpenCV 'samples' 库并让它在 armhf 上工作?
- android - 如何使用 flutter_bloc 添加 CircularProgressIndicator
- reactjs - FontAwesomeIcon 在 Reactjs 中没有改变颜色
- python - 从正态分布的 n 个值的样本中生成 N 个随机数据集?(Python)
- csv - 尝试在 QGIS 中绘制 CSV 文件的轮廓