[英]cannot choose a unique locator to click an element - selenium java krypton
I need to have a unique locator since i cannot use text because it both have facility, I need to click this我需要一个唯一的定位器,因为我不能使用文本,因为它都有工具,我需要点击这个
here is my sample code right now but it does not click这是我现在的示例代码,但它没有点击
findLink(By.xpath("//*[ng-click()='promptGroupDrawerCtrl.closeDrawer()']")).click
There are two problems with the xpath
: xpath
有两个问题:
ng-click
is an attribute, not a method. ng-click
是一个属性,而不是一个方法。 Remove the round brackets.取下圆括号。
Attribute name should start with @
属性名称应以@
开头
findLink(By.xpath("//*[@ng-click='promptGroupDrawerCtrl.closeDrawer()']")).click();
To click on the element with text as Facility you can use the following solution:要单击带有文本作为设施的元素,您可以使用以下解决方案:
findLink(By.xpath("//a[@class='h4 panel-heading panel-back panel-title btn ng-binding' and contains(@ng-click,'closeDrawer')]")).click
Note : As the element is an Angular element you have to induce WebDriverWait for the desired element to be clickable注意:由于元素是Angular元素,因此您必须引入WebDriverWait以使所需元素可点击
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.