我有以下XPath:
//div[contains(@id, 'box')]/div/h4/small/a[contains(@href, 'google')]/@href
当我在XPath Checker(Firefox扩展)中试用此XPath时,它一直都能完美运行。但是当我在Selenium中执行以下操作时:
System.out.println(selenium.getAttribute("//div[contains(@id, 'box')]/div/h4/small/a[contains(@href, 'google')]/@href"));
它不断给我以下日志错误:
14:30:56.311 INFO - Got result: OK on session 5a1401d374a04779bbe6f7fe9a0b4536 14:30:56.315 INFO - Command request: getAttribute[//div[contains(@id, 'box')]/div/h4/small/a[contains(@href, 'google')]/@href, ] on session 5a1401d374a04779bbe6f7fe9a0b4536 14:30:56.372 INFO - Got result: ERROR: Element //div[contains(@id, 'box')]/div/h4/small/a[contains(@href, 'google')]/ not found on session 5a1401d374a04779bbe6f7fe9a0b4536
我为解决这个问题而疯狂。有人看到我的代码行有任何错误吗?
该查询字符串不应该像这样(根据javadoc api)吗?
"xpath=//div[contains(@id, 'box')]/div/h4/small/a[contains(@href, 'google')]/@href"