Here is the error message I'm getting:
Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: C:\Users\Scott\workspace\Twitch%20Bot%20v2\bin\chromedriver.exe
at com.google.common.base.Preconditions.checkState(Preconditions.java:197)
at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:122)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:117)
at org.openqa.selenium.chrome.ChromeDriverService.access$0(ChromeDriverService.java:1)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:118)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:291)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:82)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:117)
at com.fatalcubez.main.Bot.setup(Bot.java:41)
at com.fatalcubez.main.Bot.<init>(Bot.java:29)
at com.fatalcubez.main.BotGUI.<init>(BotGUI.java:17)
at com.fatalcubez.main.Main.main(Main.java:14)
And here is the code that I'm using:
ClassLoader loader = ClassLoader.getSystemClassLoader();
URL path = loader.getResource("chromedriver.exe");
System.setProperty("webdriver.chrome.driver", path.getPath());
I've already check the directory for where it is searching for the chromedriver and it's there. I'm not sure what the problem is at this point. Any help would be great!
EDIT: It was simply a problem with spacing in the folder name, but now I have another problem. When I try to launch chrome it says "An administrator has installed chrome on this computer...." What can I do?
You have to give your chromeDriver.exe file path instead of taking the path from the URL.
example:
System.setProperty("webdriver.chrome.driver",
"C:\\Downloads\\chromedriver.exe");
System.setProperty("webdriver.chrome.driver",
"/home/vin/Downloads/chromedriver");
Note- write the chromedriver without mentioning .exe (In Ubuntu and Mac)
Download the chromedriver:
chromedriver link
From here unzip the folder and copy choromedriver.exe in c now set path like
Locate your chrome driver file ( for windows) in the C drive under the user and the name of your device. Using any random folder and directing to that path will not work.
System.setProperty("webdriver.chrome.driver","C:\\Users\\hp\\chromedriver.exe");
This works for me, and I think the reason is, the driver will search for the path that identifies your pc, like a default folder where they search for, as it will be more time consuming to search for random folders and can create errors when you have multiple copies of that chromedriver.exe file like I had. Thanks, hope it works!
Another thing to add, when using chromedriver with windows, you must include .exe in your systems properties call.
valid call : System.setProperty("webdriver.chrome.driver", "res/chromedriver.exe");
invalid call : System.setProperty("webdriver.chrome.driver", "res/chromedriver");
System.setProperty("webdriver.chrome.driver",
"C:\Downloads\chromedriver.exe");
Navigate to this path, right click and open the chromedriver.exe then a pop up is open Uncheck "the Always ask before open" .
this works for me
In mac OS set the path as follows
System.setProperty("webdriver.chrome.driver",
"/Users/'user_name'/Downloads/chromedriver");
go to System preferences, in Security and privacy General tab you will see open chromedriver anyway, click on it and run your program again.
It works for me
You can add the address of chrome driver exe in your code:
System.setProperty("webdriver.chrome.driver",
"/path where exe is present/chromedriver.exe");
or you can directly copy paste the exe of chrome driver in you workspace (C:\Users\Scott\workspace\Twitch Bot v2\bin\)
This worked for me:
System.setProperty("webdriver.chrome.driver", "//Users//alinapanigrahi//bin//chromedriver");
WebDriver driver=new ChromeDriver();
But I got the unknown error:
unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"686.1","isDefault":true},"id":1,"name":"","origin":"://"}
(Session info: chrome=58.0.3029.110)
Related
I have a maven project working fine with local Jenkins on Windows.
When I try to run the same test from Jenkins set up in LINUX, I am getting Firefox driver error.
selenium code:
System.setProperty("webdriver.gecko.driver", "/home/geckodriver");
FirefoxOptions options = new FirefoxOptions();
options.setHeadless(true);
options.setBinary("/usr/bin/firefox");
WebDriver driver = new FirefoxDriver(options);`
Error Message:
Specified firefox binary location does not exist or is not a real file: /usr/bin/firefox
Stacktrace:
Stacktrace
java.lang.IllegalStateException: Specified firefox binary location does not exist or is not a real file: /usr/bin/firefox
at com.google.common.base.Preconditions.checkState(Preconditions.java:504)
at org.openqa.selenium.firefox.Executable.(Executable.java:43)
at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:123)
at org.openqa.selenium.firefox.FirefoxOptions$Binary.asBinary(FirefoxOptions.java:420)
at java.util.Optional.map(Optional.java:215)
at org.openqa.selenium.firefox.FirefoxOptions.getBinaryOrNull(FirefoxOptions.java:220)
at org.openqa.selenium.firefox.FirefoxOptions.getBinary(FirefoxOptions.java:216)
at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:187)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:147)
at AutomationModules.LaunchBrowser.getDriver(LaunchBrowser.java:37)
at Validations.LoginValidation.StartBrowser(LoginValidation.java:26)
I tried not giving any binary files as well. It does not work
Expecting the test to run successfully from Jenkins
On my Ubuntu
/usr/bin/firefox -> ../lib/firefox/firefox.sh*
Which starts
/usr/lib/firefox/firefox
As I haven't changed Frirefox install location, this seems to be the default one, so probably this would work for you, too.
So try
options.setBinary("/usr/lib/firefox/firefox");
Im new to Mac OSX. Downloaded my Robotframework(Selenium & Java) project from git and tried to execute the code locally wherein I received the below error.
Suite setup failed:
IllegalStateException: The driver is not executable: /Users/roja/Documents/GitHub/testautomation/chromedrivers/chromedriver_osx
To rectify this issue, I followed the below but it didnt work.
Upgraded the selenium-java and standalone version from 2.53.1 to 3.4.0.
Driver path specified to Users/roja/automation
Chromedriver upgraded from 2.31 to 2.33
And the same driver version updated even in the path specified in the exception above.
Also Im unsure why the path is defaulted to /Users/roja/Documents/GitHub/testautomation/chromedrivers/chromedriver_osx. My git projects are saved in the path usr/local/git/testautomation and chromedriver also saved in the same. please clarify and provide me a solution.
Below code written for launching the browser,
public void LaunchBrowser() throws InterruptedException {
System.setProperty("Webdriver.chrome.driver", "/Users/roja/Automation/chromedriver_osx");
driver = new ChromeDriver();
driver.manage().window().maximize();
}
Quick installation of the latest ChromeDriver
To install the latest version of ChromeDriver:
Mac users with Homebrew:
brew tap homebrew/cask && brew cask install chromedriver
Original answered Nov 15 '17 at 12:04
The error IllegalStateException: The driver is not executable: /Users/roja/Documents/GitHub/testautomation/chromedrivers/chromedriver_osx says it all. You have to make exactly 4 changes as follows :
Change Webdriver.chrome.driver as :
webdriver.chrome.driver
Change /Users/roja/Automation/chromedriver_osx as we need to include the name of the webdriver binary i.e. chromedriver as a value :
/Users/roja/Automation/chromedriver_osx/chromedriver
Change driver = new ChromeDriver(); as :
WebDriver driver = new ChromeDriver();
Remove unwanted throws InterruptedException to keep your code short and simple.
FYI I had to do the solution proposed by varunrao321: Navigate to the folder containing chromedriver and run chmod +x chromedriver
I tried giving full permission to the chromedriver and it works fine.
chmod +x chromedriver
or
chmod 777 chromedriver
Another solution that worked for me.
Navigate to the folder containing chromedriver and run
"chmod +x chromedriver"
Worked for me as well:
Step 1: Open terminal
Step 2: Navigate to the path folder containing chromedriver
Step 3: Run chmod +x chromedriver
#debanjan already explain good expalaination to you, I am just giving you correct code:
public void LaunchBrowser() throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "/Users/roja/Automation/chromedriver_osx/chromedriver");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
}
It may be due to the permission access. Download the chrome driver using http://chromedriver.chromium.org/downloads and then give path.
Example:
System.setProperty("webdriver.chrome.driver","/Users/xyz/Downloads/chromedriver");
The way I solved this problem was by importing the chromedriver with right click>Import instead of dragging it to the folder.
I don't know exactly why, but it worked.
For me, it was the last driver that was not working with the chrome version installed on my macOS mojave. I was forced to install last version of google chrome, then it worked.
You may install chromedriver by brew
brew cask install chromedriver
After that, as DebanjanB said, replace your
System.setProperty("Webdriver.chrome.driver","/Users/roja/Automation/chromedriver_osx");
with
System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");
It works for me.
One More Solution :
Visit : https://sites.google.com/a/chromium.org/chromedriver/downloads
enter image description here
Under "Current Releases" section, Click on Chrome driver link which is updated in your system.
Automatically it will redirect to "https://chromedriver.storage.googleapis.com/index.html?path="
enter image description here
Click on link for mac and unzip the folder.
Now paste chromedriver.exe file into your project.
And provide below mentioned code-
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class SetChromeDriver {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com/");
driver.quit();
}
}
Run this command in the folder where chromedriver is present: chmod +x chromedriver
How can I use Selenium to run for Google Chrome on Mac OS? I have put the code underneath but it is still giving me an error.
System.setProperty("webdriver.chrome.driver", "/Users/STQRY/Document/Jay");
WebDriver driver = new ChromeDriver();
ERROR:
".....The driver executable is a directory: /Users/STQRY/Document/Jay"
I've copied the path straight from the file when I right clicked and selected 'Copy File'.
Little google search can tell you that.
Download the chrome_driver (chromedriver_mac32.zip ) from this link if you haven't already : https://sites.google.com/a/chromium.org/chromedriver/
Unzip it.
Provide the path as follows.
System.setProperty("webdriver.chrome.driver", "/Path/To/ChromeDriver/chromedriver_mac");
Or
System.setProperty("webdriver.chrome.driver", "/Users/xyz/abc/chromedriver_mac_2.20");
Prior to doing the below step make sure that the downloaded zip file is unzipped first
Next provide the code as specified below,
System.setProperty("webdriver.chrome.driver", "/Users/STQRY/Document/Jay/chromedriver.exe");
WebDriver driver = new ChromeDriver();
I am using WebDriver and I have downloaded the InternetExplorerDriver and was wondering what I do with it after it is downloaded?
This says to put the driver in my path. Not really certain what exactly they are talking about there.
Has anyone used this and if so could you provide detailed steps on how to set it up so it will work?
I am getting the following error:
The path to the driver executable must be set by the
webdriver.ie.driver system property
I downloaded the executables for IE and the Chrome driver. Where do I set it at?
Unpack it and place somewhere you can find it. In my example, I will assume you will place it to C:\Selenium\iexploredriver.exe
Then you have to set it up in the system. Here is the Java code pasted from my Selenium project:
File file = new File("C:/Selenium/iexploredriver.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver driver = new InternetExplorerDriver();
Basically, you have to set this property before you initialize driver
Reference:
Driver executable must be set by the webdriver.ie.driver system property
If you are using RemoteDriver things are different. From http://element34.ca/blog/iedriverserver-webdriver-and-python :
You will need to start the server using a line like
java -jar selenium-server-standalone-2.26.0.jar -Dwebdriver.ie.driver=C:\Temp\IEDriverServer.exe
I found that if the IEDriverServer.exe was in C:\Windows\System32\ or its subfolders, it couldn't be found automatically (even though System32 was in the %PATH%) or explicitly using the -D flag.
Another way to resolve this problem is:
Let's assume:
path_to_driver_directory = C:\Work\drivers\
driver = IEDriverServer.exe
When getting messsage about path you can always add path_to_driver_directory containing driver to the PATH environment variable.
Check:
http://java.com/en/download/help/path.xml
Then simply check in cmd window if driver is available - just run cmd in any location and type name of driver.
If everything works fine then you get:
C:\Users\A>IEDriverServer.exe
Started InternetExplorerDriver server (32-bit)
2.28.0.0
Listening on port 5555
Thats it.
This is just to help somebody in future.
When we initiate InternetExplorerDriver() instance in a java project it uses IEDriver.exe (downloaded by individuals) which tries to extract temporary files in user's TEMP folder when it's not in path then ur busted.
Safest way is to provide your own extract path as shown below
System.setProperty("webdriver.ie.driver.extractpath", "F:\\Study\\");
System.setProperty("webdriver.ie.driver", "F:\\Study\\IEDriverServer.exe");
System.setProperty("webdriver.ie.logfile", "F:\\Study\\IEDriverServer.log");
InternetExplorerDriver d = new InternetExplorerDriver();
d.get("http://www.google.com");
d.quit();
public class NavigateUsingAllBrowsers {
public static void main(String[] args) {
WebDriver driverFF= new FirefoxDriver();
driverFF.navigate().to("http://www.firefox.com");
File file =new File("C:/Users/mkv/workspace/ServerDrivers/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver driverIE=new InternetExplorerDriver();
driverIE.navigate().to("http://www.msn.com");
// Download Chrome Driver from http://code.google.com/p/chromedriver/downloads/list
file =new File("C:/Users/mkv/workspace/ServerDrivers/ChromeDriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
WebDriver driverChrome=new ChromeDriver();
driverChrome.navigate().to("http://www.chrome.com");
}
}
Basically you need to download the IEDriverServer.exe from Selenium HQ website without executing anything just remmeber the location where you want it
and then put the code on Eclipse like this
System.setProperty("webdriver.ie.driver", "C:\\Users\\juan.torres\\Desktop\\QA stuff\\IEDriverServer_Win32_2.32.3\\IEDriverServer.exe");
WebDriver driver= new InternetExplorerDriver();
driver.navigate().to("http://www.youtube.com/");
for the path use double slash //
ok have fun !!
Here is the exact solution, which worked in my case:
On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode".
Additionally, "Enhanced Protected Mode" must be disabled for IE 10 and higher. This option is found in the Advanced tab of the Internet Options dialog.
System.setProperty("webdriver.ie.driver","C:\\Users\\ssin22\\Downloads\\IEDriverServer_x64_2.48.0\\IEDriverServer.exe");
package Testing;
import java.io.File;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class LaunchIE {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.ie.driver","C:\\Users\\ssin22\\Downloads\\IEDriverServer_x64_2.48.0\\IEDriverServer.exe");
WebDriver driver=new InternetExplorerDriver();
driver.get("http://google.com");
}
}
using System.Text;
...
..
static void Main(String[] args){
var driver = new InternetExplorerDriver(#"C:\Users\PathToTheFolderContainingIEDriver.exe");
driver.Navigate().GoToUrl("https://www.google.com/");
Console.Read();
}
You need not include the .exe file. The path to the folder containing the .exe worked for me
WebDriverManager allows to automate the management of the binary drivers (e.g. chromedriver, geckodriver, etc.) required by Selenium WebDriver.
Link: https://github.com/bonigarcia/webdrivermanager
you can use something link this: WebDriverManager.iedriver().setup();
add the following dependency for Maven:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>x.x.x</version>
<scope>test</scope>
</dependency>
or see: https://www.toolsqa.com/selenium-webdriver/webdrivermanager/
I have chrome installed in my system. I'm using Selenium to run some tests on chrome.
I have downloaded the Chromedriver.exe to MyDocuments. I have set the 'webdriver.chrome.driver' using System.setProperty() and started ChromeDriver(). It works fine.
System.setProperty("webdriver.chrome.driver", "C:\\MyDocuments\\chromedriver.exe");
driver=new ChromeDriver();
Now, I'm trying to put Chromedriver.exe in a remote machine 'https://remotemachine/chromedriver.exe'. When I set the System property and start ChromeDriver(), I'm getting an exception, where Selenium is searching for chrome in a strange path:
The webdriver.chrome.driver defined chromedriver executable does not
exist in C:\Users..\Appdata\Local\Google
Chrome\Application...\https://remotemachine/chromedriver.exe
Why is Selenium searching for the chromedriver.exe by appending the system property to some location in C drive ?
How to launch Chrome from Selenium using a remote chromedriver.exe file ?
Not related to above, but:
Is it also possible to find the default browser binary path using Java/Selenium ?
It expects chrome to be in this location in windows
%HOMEPATH%\AppData\Local\Google\Chrome\Application\chrome.exe
For remote it has to be either in path or the -Dwebdriver.chrome.driver value should be pointing to a local chromedriver.exe location.
Local as in local to the place it is being run.
Here is the link for setup:
http://code.google.com/p/selenium/wiki/RemoteWebDriver
http://code.google.com/p/selenium/wiki/ChromeDriver
You cannot set the system path of a remote machine like -
System.setProperty("webdriver.chrome.driver", "remotemachine/chromedriver.exe");.
This code will get executed only in Hub/local machine where it resides.
To run it remotely, you need to mention -Dwebdriver.chrome.driver=pathtochromedriver.exe while starting the WD node.
java -jar seleniumserver.jar -role wd -hub http://hubhost:port/grid/register -Dwebdriver.chrome.driver=pathtochromedriver
System.setProperty("webdriver.chrome.driver", "C:\Documents and Settings\sssuppaluri\Desktop\Spicejet_Automation\chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://149.122.160.94:8443/skylights/cgi-bin/skylights.cgi");
Create a new folder within your project called "chromedriver" and place the "chromedriver.exe" file in it then add the following line to your code
System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+"\\chromedriver\\chromedriver.exe");