Angular 量角器/角度传感器无法单击可单击图标
我有以下量角器/角度脚本:Angular 量角器/角度传感器无法单击可单击图标,angular,protractor,internet-explorer-11,url-redirection,Angular,Protractor,Internet Explorer 11,Url Redirection,我有以下量角器/角度脚本: clickAppMenuIcon() { var EC = protractor.ExpectedConditions; var menuLayer = element(by.id('cdk-overlay-2')); expect(menuLayer.isPresent()).toBe(true) .then(function (){ console.log('menu Layer shows'); v
clickAppMenuIcon() {
var EC = protractor.ExpectedConditions;
var menuLayer = element(by.id('cdk-overlay-2'));
expect(menuLayer.isPresent()).toBe(true)
.then(function (){
console.log('menu Layer shows');
var menuGrid = element(by.css('.menu-grid'));
expect(menuGrid.isPresent()).toBe(true)
.then(function () {
console.log('menu-grid shows');
browser.executeScript('' +
'var zIndexElement0 = document.getElementById("app-container");' +
'zIndexElement0.style.zIndex = "-20";' +
'var zIndexElement1 = document.getElementById("cdk-overlay-2");' +
'zIndexElement1.style.zIndex = "20";'
);
menuGrid.click();
var menuIcon = element(by.css('a[title=Configuration]'));
expect(menuIcon.isPresent()).toBe(true)
.then(function() {
console.log("menu Icon is present");
menuIcon.click();
var routerLinkIcon = element.all(by.css('.material-icons'));
expect(routerLinkIcon.isPresent()).toBe(true)
.then(function (){
console.log("it's there");
routerLinkIcon.click();
// browser.wait(function (){
// expect(browser.driver.getCurrentUrl()).toEqual('http://10.22.1.68:8080/configuration');
// },5000);
expect(browser.driver.getCurrentUrl()).toEqual('http://10.22.1.68:8080/configuration');
});
});
});
});
}
这适用于角度HTML:
<mat-card _ngcontent-c8="" class="app-menu mat-card ng-star-inserted">
<div _ngcontent-c8="" class="menu-grid">
<a _ngcontent-c8="" title="NPW">
<i _ngcontent-c8="" class="material-icons">account_balance</i>
</a>
<a _ngcontent-c8="" title="Upload">
<i _ngcontent-c8="" class="material-icons">file_upload</i>
</a>
<a _ngcontent-c8="" title="Correlate">
<i _ngcontent-c8="" class="material-icons">share</i>
</a>
<a _ngcontent-c8="" routerlink="workspaces" title="Workspace" ng-reflect-query-params="[object Object]" ng-reflect-router-link="workspaces" href="/workspaces">
<i _ngcontent-c8="" class="material-icons">content_copy</i>
</a>
<a _ngcontent-c8="" title="Help">
<i _ngcontent-c8="" class="material-icons">help</i>
</a>
<a _ngcontent-c8="" title="Send Notification">
<i _ngcontent-c8="" class="material-icons">add_alert</i>
</a>
<a _ngcontent-c8="" routerlink="configuration" title="Configuration" ng-reflect-router-link="configuration" href="/configuration">
<i _ngcontent-c8="" class="material-icons">settings_applications</i>
</a>
</div>
</mat-card>
它在控制台中返回它找到了它,然后应该可以单击它将URL重定向到新的URL,但它似乎坐在那里,除了返回此错误外,什么也不做:
**************************************************
* Failures *
**************************************************
1) ConfigNavCheck should navigate to Configuration page on click
- Failed: Element not clickable at point (450,676). Other element would receive the click: <div class="mat-button-ripple mat-ripple mat-button-ripple-round" ng-reflect-disabled="false" ng-reflect-trigger="[object HTMLButtonElement]" matRipple="" ng-reflect-centered="true"></div>
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z'
System info: host: 'A0000872', ip: '10.22.73.23', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: driver.version: unknown
Executed 1 of 1 spec (1 FAILED) in 20 secs.
[13:58:50] I/local - Shutting down selenium standalone server.
[13:58:50] I/launcher - 0 instance(s) of WebDriver still running
[13:58:50] I/launcher - internet explorer #01 failed 1 test(s)
[13:58:50] I/launcher - overall: 1 failed spec(s)
[13:58:50] E/launcher - Process exited with error code 1
**************************************************
*失败*
**************************************************
1) ConfigNavCheck应在单击时导航到配置页面
-失败:元素在点(450676)处不可单击。其他元素将收到单击:
构建信息:版本:“3.12.0”,修订版:“7c6e0b3”,时间:“2018-05-08T15:15:08.936Z”
系统信息:主机:'A0000872',ip:'10.22.73.23',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.8.0_77'
驱动程序信息:驱动程序。版本:未知
在20秒内执行了1个规格中的1个(1个失败)。
[13:58:50]I/local-关闭selenium独立服务器。
[13:58:50]I/launcher-WebDriver的0个实例仍在运行
[13:58:50]I/launcher-internet explorer#01测试失败1次
[13:58:50]I/launcher-总体:1个规格失败
[13:58:50]E/launcher-进程已退出,错误代码为1
如何将页面重定向到单击的链接。我们尝试过等待,但它超时了。我们还有一个简单得多的版本,可以与Chrome和Firefox配合使用,但不适用于IE11。IE必须得到支持,所以这是必要的。我知道这样做会招致一些不好的评论,但至少在Chrome和Firefox中是有效的 browser.executeScript('document.querySelector(\'[routerlink=“configuration”]\')。单击();') 现在,如果您在单击某个元素时遇到问题,而其他元素会被单击,正如我在许多量角器登录问题中看到的那样,您可以使用:
changeZindexById(zIndexLayer, level) {
console.log('zIndex level: ' + level);
browser.executeScript('' +
'var zIndexElement = document.getElementByID("' + zIndexLayer + '");' +
'zIndexElement.style.zIndex = "' + level + '";'
);
}
changeZindexByClass(zIndexLayer, level) {
console.log('zIndex level: ' + level);
browser.executeScript('' +
'var zIndexElement = document.getElementsByClassName("' + zIndexLayer + '");' +
'zIndexElement[0].style.zIndex = "' + level + '";'
);
}
如果您能为我们指出行
450
,那将非常有用。在代码中我看到两次单击:menuGrid.click()代码>和路由器链接图标。单击()代码>@lealceldero很抱歉在复制时错过了它。谢谢你的回复。单击菜单图标
现在就在那里了。还有,这就是为什么如此奇怪,以至于我几乎已经确定了在哪里单击两次,并尝试单击确定的位置,但没有成功。