动态分配的ID

时间:2017-06-12 17:36:07

标签: javascript gmail protractor

目标:浏览Gmail,然后点击收件箱中的链接。

到目前为止,我已经:使用用户名和密码成功登录gmail,并使用Protractor打开第一个显示的电子邮件。

问题:每次加载网页并检查HTML代码以引用电子邮件中的链接时,类名和ID都不同。例如,上次xpath为://*[@id=":6d"]/a,但现在为//*[@id=":ml"]/a

元素: <a href= "the desired link" target="_blank" data-saferedirecturl="the desired link v2" > change Account password.</a> == $0

上面的所有超类都包含如下代码:<div id=":66" class="ii gt adP ad0>,它们似乎是动态创建的。

您如何推荐引用该链接? 提前致谢

1 个答案:

答案 0 :(得分:1)

by.linkTextby.partialLinkText是两个最相关的定位器:

element(by.partialLinkText("change Account password")).sendKeys("test");

(确保字母大小写正确)。

相关问题