Execute Selenium WebDriver scripts in IE browser,Firefox browser and Chrome browser
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class IEFirefoxChromeBrowsers {
/*
Open IE , Go to Tools -> Internet Options -> Security
Set all zones to the same protected mode, enabled or disabled should not matter.
Finally, set Zoom level to 100% by right clicking on the gear located at the top right corner and enabling the status-bar. Default zoom level is now displayed at the lower right.
*/
@Test
public void ieBrowser() throws InterruptedException {
System.setProperty("webdriver.ie.driver", "E:\\Selenium\\IEDriverServer\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("http://docs.seleniumhq.org/");
Thread.sleep(3000);
driver.close();
}
// No settings required for firefox execution.
@Test
public void fireFoxBrowser() throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.co.in");
Thread.sleep(3000);
driver.close();
}
// Download chromedriver.exe and write the code like below.
@Test
public void chromeBrowser() throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "E:\\Selenium\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://docs.seleniumhq.org/");
Thread.sleep(3000);
driver.close();
}
}
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class IEFirefoxChromeBrowsers {
/*
Open IE , Go to Tools -> Internet Options -> Security
Set all zones to the same protected mode, enabled or disabled should not matter.
Finally, set Zoom level to 100% by right clicking on the gear located at the top right corner and enabling the status-bar. Default zoom level is now displayed at the lower right.
*/
@Test
public void ieBrowser() throws InterruptedException {
System.setProperty("webdriver.ie.driver", "E:\\Selenium\\IEDriverServer\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("http://docs.seleniumhq.org/");
Thread.sleep(3000);
driver.close();
}
// No settings required for firefox execution.
@Test
public void fireFoxBrowser() throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.co.in");
Thread.sleep(3000);
driver.close();
}
// Download chromedriver.exe and write the code like below.
@Test
public void chromeBrowser() throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "E:\\Selenium\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://docs.seleniumhq.org/");
Thread.sleep(3000);
driver.close();
}
}
No comments:
Post a Comment