Pages

Wednesday, November 27, 2013

How to avoid full page load | Webdriver


Clicking an Element on page load is even possible on webdriver; By default, webdriver wait for the entire page to load and then picks the element. The links and texts are visible but they are not clickable; However, it works well on Selenium IDE picking elements on page load.

Webdriver make use of the FirefoxProfile to avoid such risks; It's applicable only for Firefox browser.

FirefoxProfile fp = new FirefoxProfile();
fp.setPreference("webdriver.load.strategy", "unstable");
driver = new FirefoxDriver(fp);
baseUrl = "http://xyz.com";
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);


driver.navigate().to("http://xyz.com");
driver.findElement(By.xpath(Value)).click();
System.out.println("Button got clicked");

No comments:

Post a Comment