I would like to open url in chrome driver by applying object repository concept. Below given is my selenium programme which contain two file one is testng file and another one is config.property filechromedriver="E:\\selenium bwosers\\chromedriver.exe"
url="https://www.google.co.in"
I saved above programme as config.property in configuration folder
package sele_prac_pkg;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class Object_repo
{
@Test
public void f() throws Exception
{
File file=new File("./configuration/config.property");
FileInputStream fis=new FileInputStream(file);
Properties pro=new Properties();
pro.load(fis);
String url_var=pro.getProperty("url");
String chromedriver_var=pro.getProperty("chromedriver");
System.setProperty("webdriver.chrome.driver",chromedriver_var);
WebDriver driver=new ChromeDriver();
driver.get(url_var);
}
}
when i execute above code it shwoig java.lang.IllegalStateException: The driver executable does not exist error
Two things
- You don't have to put quotes around the values in property files
- are you sure you have given the right path, to me it looks like spelling mistake selenium bwosers shouldn't it be selenium browsers
(Below is the example of my code i am getting an error) import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver;
public class FirstScript {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","/Users/rahulgudi/Downloads");
WebDriver driver = new ChromeDriver();
driver.get("http://google.com");
}
Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: /Users/rahulgudi/Downloads/SeleniumProject
来源:https://stackoverflow.com/questions/38283631/java-lang-illegalstateexception-the-driver-executable-does-not-exist-chrome-dri