How to run webdriver in chrome browser?:
==================================
To run selenium webdriver in Chrome browser, we need download Chrome Driver.
Download latest version of Chrome Driver server for webdriver from seleniumhq.org.
In order to launch Chrome we need to set the 2 attributes see the synatx.
syntax:
=======
System.setProperty("webdriver.chrome.driver", "path of CHROMEDriverServer.exe");
==================================
To run selenium webdriver in Chrome browser, we need download Chrome Driver.
Download latest version of Chrome Driver server for webdriver from seleniumhq.org.
In order to launch Chrome we need to set the 2 attributes see the synatx.
syntax:
=======
System.setProperty("webdriver.chrome.driver", "path of CHROMEDriverServer.exe");
Example:
======
package blog;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
public class IeDemo {
WebDriver webDriver;
@BeforeSuite
public void launchingIEBrowser() {
System.setProperty("webdriver.chrome.driver", "D:\\Ramesh\\ChromeDriver.exe");
webDriver = new InternetExplorerDriver();
webDriver.manage().window().maximize();
webDriver.manage().deleteAllCookies();
webDriver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS);
}
@Test
public void testScript() {
webDriver.get("https://google.com");
webDriver.findElement(By.name("q")).sendKeys("selenium by ramesh");
webDriver.findElement(By.name("btNg")).click();
}
@AfterSuite
public void closeBrowser() {
webDriver.quit();
}
}
No comments:
Post a Comment