如何获得具有 ng-bulding 类的跨度值? [英] How to get span value which has ng-bulding class?
本文介绍了如何获得具有 ng-bulding 类的跨度值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在控制台上尝试使用以下方法时,我可以获得价值:
$x("///*[@class='file-folder-breadcrumbs-item-part name']")[1].innerText;
或
document.querySelector("[ng-if='currentPathNodes.length']").innerText;
但无法在量角器代码中转换此 JavaScript 代码.
下面是 HTML
<!-- end ngRepeat: child in root.nodes -->
解决方案
我认为这就是您要找的:
const breadcrumbPart = element.all(by.css('.file-folder-breadcrumbs-item-part.name').first();const myText = await breadcrumbPart.getText();//console.log(myText);期望(myText).toEqual('something');
或同步解决方案:
const breadcrumbPart = element.all(by.css('.file-folder-breadcrumbs-item-part.name').first();breadcrumbPart.getText().then(myText => {//console.log(myText);期望(myText).toEqual('something');});
I can get value when I tried this on console using:
$x("//*[@class='file-folder-breadcrumbs-item-part name']")[1].innerText;
or
document.querySelector("[ng-if='currentPathNodes.length']").innerText;
but not able to convert in this JavaScript code in Protractor code.
Below is HTML
<div class="file-folder-breadcrumbs-child-panel ng-hide" ng-shenter image ow="isExpanded(root.full)">
<!-- ngRepeat: child in root.nodes -->
<div ng-repeat="child in root.nodes" class="ui-state-default filedrop file-folder-breadcrumbs-item-child ng-scope" ng-click="navigateToChild($event, child, root)">
<span class="ng-binding">TestFolder</span>
</div>
<!-- end ngRepeat: child in root.nodes -->
</div>
解决方案
I think this is what you are looking for:
const breadcrumbPart = element.all(by.css('.file-folder-breadcrumbs-item-part.name').first();
const myText = await breadcrumbPart.getText();
// console.log(myText);
expect(myText).toEqual('something');
Or synchronous solution:
const breadcrumbPart = element.all(by.css('.file-folder-breadcrumbs-item-part.name').first();
breadcrumbPart.getText().then(myText => {
// console.log(myText);
expect(myText).toEqual('something');
});
这篇关于如何获得具有 ng-bulding 类的跨度值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文