我有以下XPath:元素在XPath的檢查發現,而不是在硒
//div[contains(@id, 'box')]/div/h4/small/a[contains(@href, 'google')]/@href
當我嘗試了這個XPath的XPath的檢查器(Firefox擴展),它完美的作品所有的時間。但是,當我這樣做的硒:
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
我要瘋了,以解決這個問題。有沒有人看到我的代碼行中有任何錯誤?
您是否在使用Selenium RC? – 2013-09-05 08:59:03