如何获取具有 ng-building class 的跨度值?
How to get span value which has ng-bulding class?
当我在控制台上尝试此操作时,我可以获得价值:
$x("//*[@class='file-folder-breadcrumbs-item-part name']")[1].innerText;
或
document.querySelector("[ng-if='currentPathNodes.length']").innerText;
但无法在 Protractor 代码中转换此 JavaScript 代码。
下面是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>
我想这就是您要找的:
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');
或同步解:
const breadcrumbPart = element.all(by.css('.file-folder-breadcrumbs-item-part.name').first();
breadcrumbPart.getText().then(myText => {
// console.log(myText);
expect(myText).toEqual('something');
});
当我在控制台上尝试此操作时,我可以获得价值:
$x("//*[@class='file-folder-breadcrumbs-item-part name']")[1].innerText;
或
document.querySelector("[ng-if='currentPathNodes.length']").innerText;
但无法在 Protractor 代码中转换此 JavaScript 代码。
下面是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>
我想这就是您要找的:
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');
或同步解:
const breadcrumbPart = element.all(by.css('.file-folder-breadcrumbs-item-part.name').first();
breadcrumbPart.getText().then(myText => {
// console.log(myText);
expect(myText).toEqual('something');
});