gpt4 book ai didi

angularjs - 如何使用 Protractor 识别 ionic 标签?

转载 作者:行者123 更新时间:2023-12-01 06:26:11 25 4
gpt4 key购买 nike

我有一个简单的 ionic 模板,如下所示。在 Protractor 中,我如何编写定位器来定位 ionic 元素,比如标题和左右按钮。如何检查标题是否为“我的标题”?我无法通过 H1 绑定(bind),因为据说我的模板中有很多 H1。

<ion-header-bar align-title="left" class="bar-positive">
<div class="buttons">
<button class="button" ng-click="doSomething()">Left Button</button>
</div>
<h1 class="title">My Title</h1>
<div class="buttons">
<button class="button">Right Button</button>
</div>
</ion-header-bar>
<ion-content>
Some content!
</ion-content>

最佳答案

我会找到元素 by xpath依赖于它们的标签名称、类和相对位置:

var title = element(by.xpath('//h1[@class="title" and following-sibling::div[@class="buttons"] and preceding-sibling::div[@class="buttons"]'));
var leftButton = title.element('preceding-sibling::div[@class="buttons"]/button');
var rightButton = title.element('following-sibling::div[@class="buttons"]/button');

关于angularjs - 如何使用 Protractor 识别 ionic 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28351351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com