Monday, 30 September 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");

5 comments:

  1. Is there any way to make this happen in Internet Explorer ?
    Thanks in advance

    ReplyDelete
  2. Also I am trying for scripts to automate an already opened web page in IE. In order to skip the beginning formalities of logging in and working around to reach the page every time.
    Please help me on this too .. thanks :)

    ReplyDelete
  3. Thanks for the great information in your blog Selenium Training in Chennai

    ReplyDelete