Reputation: 1158
When I am trying to click on the Link using below line of code using FirefoxDriver
it is working fine.
WebDriver driver = new FirefoxDriver();
driver.findElement(By.linkText("More...")).click();
But when i use HtmlUnitDriver
then i am getting below exception.
org.openqa.selenium.NoSuchElementException: No link found with text: More...
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_24'
Driver info: driver.version: HtmlUnitDriver
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByLinkText(HtmlUnitDriver.java:630)
at org.openqa.selenium.By$2.findElement(By.java:93)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$4.call(HtmlUnitDriver.java:1198)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$4.call(HtmlUnitDriver.java:1)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:934)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:1195)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:377)
at com.search.engine.BotwSearchEngine.isPageExists(BotwSearchEngine.java:154)
at com.search.engine.BotwSearchEngine.searchCategories(BotwSearchEngine.java:82)
at com.search.engine.BotwSearchEngine.main(BotwSearchEngine.java:189)
Please help me to resolve this issue.
Upvotes: 0
Views: 2345
Reputation: 8223
Is it possible that the link is not present on the initial load of the page, and added subsequently using JavaScript? If so, you might was to check that you have JavaScript enabled when you create the HTMLDriver instance: WebDriver driver = new HTMLUnitDriver(true);
http://code.google.com/p/selenium/wiki/HtmlUnitDriver
Upvotes: 1