我确定了一个独特的网络元素为:
ng-click="navigateToNewCustomer('New Customer')"
如何为此编写xpath?当我编写xpath时,由于我使用双引号,因此会引发错误。
//*[@ng-click="navigateToNewCustomer('New Customer')"].click();
答案 0 :(得分:3)
您可以使用反斜杠转义双引号:
//*[@ng-click=\"navigateToNewCustomer('New Customer')\"].click();
答案 1 :(得分:-1)
要将 WebElement 标识为:
webelement ng-click="navigateToNewCustomer('New Customer')"
您可以使用以下两个 XPaths :
使用navigateToNewCustomer
:
"//*[starts-with(@ng-click,'navigateToNewCustomer')]"
使用New Customer
:
"//*[contains(@ng-click, 'New Customer')]"
使用navigateToNewCustomer
和New Customer
:
"//*[starts-with(@ng-click,'navigateToNewCustomer') and contains(@ng-click, 'New Customer')]"