java - How to resolve NoSuchElementException in HtmlUnitDriver -
i trying run script in background using htmlunitdriver throwing nosuchelementexection every time,but getting current url.
import java.util.concurrent.timeunit; import org.openqa.selenium.by; import org.openqa.selenium.webdriver; import org.openqa.selenium.htmlunit.htmlunitdriver; public class example{ public static void main(string[] args) { webdriver driver = new htmlunitdriver(true); driver.get("http://www.google.com"); string url=driver.getcurrenturl(); driver.manage().timeouts().implicitlywait(5, timeunit.seconds); system.out.println(url); string text=driver.findelement(by.id("gbqfba")).gettext(); system.out.println(text); driver.findelement(by.xpath("//*[@id='gbqfba']")).getsize().getheight(); driver.findelement(by.xpath("//*[@id='gbqfba']")).getsize().getwidth(); driver.findelement(by.xpath("//*[@id='gbqfba']")).click(); driver.quit();
} }
did try adding thread.sleep see if timing problem?
Comments
Post a Comment