Monday, February 25, 2013

How to work with Internet Explorer(IE) browser using Webdriver.


Download the "IEDriverServer.exe" and keep it in your local storage.

http://code.google.com/p/selenium/downloads/list


How to define:

System.setProperty("webdriver.ie.driver","Specify the "IEDriverServer.exe" file path);

//File path example: "C:\\Sakthi\\Softwares\\IE Driver\\IEDriverServer.exe".

WebDriver driver=new InternetExplorerDriver();

driver.get("http://spreadsheetpage.com/index.php/file/");


Code Example:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class ClosePopupIE
{
    public static void main(String[] args)
    {
        try
        {
        System.setProperty("webdriver.ie.driver","C:\\Sakthi\\Softwares\\IE Driver\\IEDriverServer.exe");

        WebDriver driver=new InternetExplorerDriver();
        driver.get("http://spreadsheetpage.com/index.php/file/");
        driver.findElement(By.linkText("amazon_referrals_2009.xlsx")).click();
       driver.close();
        }
        catch(Exception e)
        {
            System.out.print(e);
        }

    }     
  
}

No comments:

Post a Comment