IE Browser using Selenium Webdriver: "The driver executable is a directory" - java

I am getting the following error while trying to launch an IE browser using Selenium Webdriver. What seems to be the problem?
Exception in thread "main" java.lang.IllegalStateException: The driver executable is a directory: D:\Bhavesh\Bhavesh_Data\Study\Selenium\IEDriverServer_x64_2.45.0
at com.google.common.base.Preconditions.checkState(Preconditions.java:197)
at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:119)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:112)
at org.openqa.selenium.ie.InternetExplorerDriverService.access$1(InternetExplorerDriverService.java:1)
at org.openqa.selenium.ie.InternetExplorerDriverService$Builder.build(InternetExplorerDriverService.java:247)
at org.openqa.selenium.ie.InternetExplorerDriver.setupService(InternetExplorerDriver.java:251)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:172)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:146)
at first.IEDriver.main(IEDriver.java:11)

As per my understanding, when you set property for IEDriver location, you did not mentioned the full path (full directory path including iedriver exe)
For example.. Consider the following..
if you placed your IEDriverServer.exe in "D:/IEdriver" , then you have to set the property as follows:-
Right Approach:- System.setProperty("webdriver.ie.driver", "D:/IEdriver/IEDriverServer.exe");
Wrong approach :- System.setProperty("webdriver.ie.driver", "D:/IEdriver");
Let me know if it helps

I think there might be an issue in setting up the executable property..
Set the executable property as below
File file = new File("C:/Seleniumjars/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
driver = new InternetExplorerDriver();
}

Check path to driver, click on driver by right button in IDE and copy path to folder
Try to change path to something like this (with backslashes):
System.setProperty("webdriver.chrome.driver",
new File("C:\\QA\\neoAutomation\\src\\main\\resources\\drivers\\chromedriver.exe")
.getAbsolutePath());
return new ChromeDriver(getCapabilities(browser));

Add one folder and add all the drivers needed.
Now copy the path of the driver from properties and use it in set property example.
System.setProperty("webdriver.chrome.driver","C:\\Users\\arumugam\\eclipse-workspace\\FirstTestNG\\driversdirector\\chromedriver.exe");

Related

java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property-The Similiar doesn't ans

Trying to learn Selenium , I opened the similar question but nothing seemed to help.
My code
package seleniumPractice;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class seleniumPractice {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("https://google.com");
driver.quit();
}
}
My Errors :-
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from https://chromedriver.storage.googleapis.com/index.html
at org.openqa.selenium.internal.Require$StateChecker.nonNull(Require.java:311)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:135)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:38)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:231)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:437)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:127)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:48)
at seleniumPractice.seleniumPractice.main(seleniumPractice.java:8)
It's the same issue as previous questions.
Please add the following lines to your code changing "C:\stack\overflow\chromeDriver.exe" to the absolute path of your chromedriver.exe in your device.
System.setProperty("webdriver.chrome.driver", "C:\\stack\\overflow\\chromeDriver.exe");
WebDriver driver = new ChromeDriver();
Please note absolute paths follow the standard used in the answer here:
How do I get the file name from a String containing the Absolute file path?
They require the double \ while windows will give you / if you copy the path from file explorer or similar. You need to replace each / with \ for things to work
This wouldn't be an issue if you had set up chromedriver as an system variable and pointed to your file. That is what my lines of code are doing.

Java Selenium ChromeDriver executable does not exist

I looked everywhere and I don't know what am I doing wrong here. It would be really helpful if you could guys help me out.
Code:
System.setProperty("webdriver.chrome.driver","/Users/eshanmostafa/eclipse-
workspace/TestNG/chromedriver");
WebDriver driver = new ChromeDriver();
driver.manage().window().fullscreen();
driver.manage().deleteAllCookies();
driver.manage().timeouts().pageLoadTimeout(40,TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(40,TimeUnit.SECONDS);
}
Error Message:
FAILED CONFIGURATION: #BeforeMethod setUp
java.lang.IllegalStateException: The driver executable does not exist: /Users/eshanmostafa/eclipse-workspace/TestNG/chromedriver
at com.google.common.base.Preconditions.checkState(Preconditions.java:585)
at
Are you using macbook? you need to change driver exe file as executable file then refresh project and try again

Unable to find Matching Set of Capabilities and ChromeDriver

Here is the situation. I downloaded the chrome webdriver, unzipped the file, and went through the steps for setting the path through system properties. I am still unable to open chrome from Eclipse. Please help.
Unable to find matching set of capabilities
You are giving wrong parameter in system properties
Gecko driver is for firefox
If you have already downloaded chrome driver simply replace geckodriver.exe with chromedriver.exe.Otherwise, Download chrome driver and place it in your folder given in system properties and run your code.
Your code will appear as:
System.setProperty("webdriver.chrome.driver", "C:\\Users\\...\\Drivers\\chromedriver.exe");
// **Note**: complete your path above
driver = new ChromeDriver();

How to run selenium tests in Chrome browser?

I have some tests using JUnit and Selenium, and I need to run it on the Chrome browser. I downloaded the Chrome driver, and configure my SetUp() as:
#Before
public void SetUp() throws Exception{
System.setProperty("webdriver.chrome.driver","");
driver = new ChromeDriver();
baseUrl = ;
driver.get(baseUrl);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);//Wait 5 seconds to load the page
}
The ChromeDriver.exe are added in my "Referenced Libraries" folder.
When I'll run the tests, the following error is displayed:
java.lang.exception: No runnable methods
Anybody know how can I fix this?
SOLUTION
1º Add the chromedriver in the path of your computer.
2º Update your setProperty as: System.setProperty("webdriver.chrome.driver","C:\\Users\\pedro_nazario\\Desktop\\ChromeDriver\\chromedriver.exe");
The second parameter must be the way where is your Chromedriver.exe in my case, the chromedriver are in a folder on desktop.
The most important thing, that you never forget
When you'll run the tests, before, close your Chrome browser completely. Any chrome browser must be open before you run your tests. If have some chrome browser opened, the selenium will take a error in your screen.
According to the documentation, webdriver.chrome.driver should contain the path to the chromedriver executable:
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
Alternatively, you can add path to the chromedriver to the PATH environment variable.

How do I run Firebug within Selenium WebDriver (Selenium 2)?

What's the best way to activate Firebug in Firefox when running Selenium 2?
Edit: Ok, I realize "best" is open to interpretation, but the profile-based solution really used to be a pain with selenium 1.0. So any alternative is considered better until proved worse ;)
You can create your profile in code and dynamically add required add-ons. Let's assume that you saved Firebug XPI into the C:\FF_Profile folder as firebug.xpi (go to Firebug download page, right-click on the "Add To Firefox" and save as C:\FF_Profile\firebug.xpi).
In code:
final String firebugPath = "C:\\FF_Profile\\firebug.xpi";
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(new File(firebugPath));
// Add more if needed
WebDriver driver = new FirefoxDriver(profile);
This is described in WebDriver FAQ
Do you mean having firebug installed in the browser instance that webdriver launches? If so, you can pass an extension when you instantiate the driver, but the eaisest way is to create a firefox profile with firebug installed and then use the following code before you instantiate the driver:
System.setProperty("webdriver.firefox.profile", "NAME_OF_FIREFOX_PROFILE_WITH_FIREBUG");
Just reference your profile by name. Example in Ruby:
#driver = Selenium::WebDriver.for :firefox, :profile => "default"
Then, load Firefox normally, and add your desired extensions. They will now show up in your Selenium test runs.
Apparently the way the firefox-profile options are consumed has changed in Selenium WebDriver.
The old commandline (Selenium RC):
java -jar selenium-2.28.0.jar -firefoxProfileTemplate ~/.mozilla/firefox/3knu5vz0.selenium
Updated for WebDriver: (note that it wants the profile name rather than the directory)
java -jar selenium-2.28.0.jar -Dwebdriver.firefox.profile=selenium
modify your firefox location to something like
C:\Users\user-name\AppData\Roaming\Mozilla\Firefox\Profiles\sgmqi7hy.default
launch your firefox from selenium / webdriver
make all your required settings
close and restart firefox browser from selenium / webdriver
that's it, it solves your problem !!
I found a profiles.ini in ~/.mozialla/firefox/. In there was a profile named default, which I specified a like the following and then firefox was opened in test just like I opened it regularly (with all plugins etc).
java -jar selenium.jar -Dwebdriver.firefox.profile=default
If none of the above option works. Then try this.
1) Open terminal and type below command (close all existing firefox
sessions first)
firefox -p
2) This will open an option to create a new Firefox profile.
3) Create a profile lets say "SELENIUM".
4) Once the firefox is open straight away install firebug or any
other plugins extension that you want. once done close the window.
5) Now load this new profile via selenium , use below java
statements.
ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.getProfile("SELENIUM");
WebDriver driver = new FirefoxDriver(ffprofile);
6) Done. Enjoy.
I have observed that the firebug is adding to browser and it is disabled by default and not enabled ,when i add firebug to firefox at runtime by using webdriver. So to make it enable we may need to add the below line to profile.
profile.setEnableNativeEvents(true);
Assuming that, Firebug is installed. Your objective is to run Firebug. Firebug can be run/execute by pressing F12 key. So Firebug can be run by following command of Selenium WebDriver with Java:
Actions action = new Actions(driver);
action.sendKeys(Keys.F12).build().perform();

Categories