-
Notifications
You must be signed in to change notification settings - Fork 1
Switching to chrome
Praveen Garg edited this page Jun 18, 2016
·
3 revisions
@@ -7,7 +7,7 @@ import static org.junit.Assert.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
-import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
public class TestExampleWeb1 {
@@ -16,10 +16,10 @@ public class TestExampleWeb1 {
@Test
public void testTitle(){
- // Create a new instance of the Firefox driver
+ // Create a new instance of the Chrome driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
- driver = new FirefoxDriver();
+ driver = new ChromeDriver();
On execution of the test, We encountered an error message:
java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Solution:
- Download the chrome driver as per the OS you are using.
- Just before the line
driver = new ChromeDriver();
set system property with following syntax.
System.setproperty(key, value);
Key = "webdriver.chrome.driver" Value = "chromedriver.{extension}", Absolute path of chromedriver
Note: We will be seeing how to automate this task using gradle (we will bridge maven-gradle).