是xpath的id參數是動態的成幀xpath表達式 - 下面的webdriver用java
sampels:
//*[@id="00e46000000UZ8a_RelatedCustomPermissionsSecurityList_page"]/div[1]/div"
//*[@id='00e6F000001ffnh_RelatedCustomPermissionsSecurityList_page']/div[1]/div
所以15位動態生成開始時,所以我試圖找到下面的XPath
//[ends-with(@id,'_RelatedCustomPermissionsSecurityList_page')]/div[1]/div
在執行我得到下面的錯誤
元素invalid selector: Unable to locate an element with the xpath expression //[ends-with(@id,'_RelatedCustomPermissionsSecurityList_page')]/div[1]/div because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//[ends-with(@id,'_RelatedCustomPermissionsSecurityList_page')]/div[1]/div' is not a valid XPath expression.
感謝,含有不工作,但串其工作,可以請你澄清爲何含有不工作? – Prabu
你的意思是元素不能用'contains()'找到,否則你仍然會得到'invalid selector'異常? – Andersson
使用// * [包含(@id,'_ RelatedCustomPermissionsSecurityList_page')]/div [1]/div得到同樣的異常,這是我的問題 – Prabu