Element is found in XPath Checker but not in Selenium Element is found in XPath Checker but not in Selenium selenium selenium

Element is found in XPath Checker but not in Selenium


Shouldn't that query string look like this (according to javadoc api)?

"xpath=//div[contains(@id, 'box')]/div/h4/small/a[contains(@href, 'google')]/@href"


According to the API doc, it should be

...getAttribute("xpath=//div[contains....


In Selenium RC: it needs to mention xpath as "xpath=//div[contains(@id, 'box')]/div/h4/small/a[contains(@href, 'google')]/@href". So in your case, the code is as below:

selenium.getAttribute("xpath=//div[contains(@id, 'box')]/div/h4/small/a[contains(@href, 'google')]/@href");

In Selenium WebDriver: the code is as below:

driver.findElement(By.xpath("//div[contains(@id, 'box')]/div/h4/small/a[contains(@href, 'google')]/@href")).getAttribute("The name of the attribute");