2

I have this code to set system properties:

System.setProperty("webdriver.chrome.driver", "src\\main\\resources\\driver\\chromedriver.exe");

Is it possible to store chromedriver executable within GitHub and use it in different projects? Something like this:

System.setProperty("webdriver.chrome.driver", "https://path_to_file/chromedriver.exe");
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
S.Manko
  • 151
  • 1
  • 2
  • 15
  • You could create a project that contains the various libraries and drivers related to Selenium and then include that project in your other projects so that you only have to maintain a single project as far as driver versions, etc. I wouldn't necessarily recommend this but you could do it. – JeffC Feb 26 '19 at 21:23
  • Possible duplicate of [CreatePlatformSocket() returned an error: An invalid argument was supplied. (0x2726) when trying to access chromedriver through network path](https://stackoverflow.com/questions/51056121/createplatformsocket-returned-an-error-an-invalid-argument-was-supplied-0x2) – JeffC Feb 26 '19 at 21:24

3 Answers3

2

The open source WebDriverManager may be the closest solution to what you are asking for.

WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();

This code will take care of downloading the right webdriver executable for your platform if needed and setting up the environment.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Jens Dibbern
  • 1,434
  • 2
  • 13
  • 20
0

I don't think it is possible because :

WebDriver using protocols to communicate with browser and It known asWebDriver JSON Wire Protocol, which is actually a RESTful web service using JSON over HTTP.

Here is a explanation of how it works : https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol

So, using the driver as you want, you should run that driver.exe on external source and you should communicate with it via selenium. There is only way to do what you want is improving and adding so much codes to selenium's source code.

sayhan
  • 1,168
  • 1
  • 16
  • 22
0

First of all hhttps://path_to_file/.. is an URL, conversationally termed a web address is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. A URL is a specific type of Uniform Resource Identifier (URI). HTTP protocol enables/allows the client application (usually a web browser) to create HTTP requests containing the name of the web site it wants to contact for information exchange.


chromedriver executable location

In Troubleshooting - ChromeDriver it is mentioned that,

The path to the chromedriver executable must be set by the webdriver.chrome.driver system property and the chromedriver binary must be in the system path.

So, Selenium's client expects the WebDriver executable to be in PATH i.e. the location of the WebDriver executable to be added within the OS native PATH variable.


Conclusion

So it can be concluded that it won't be possible to store the WebDriver executable within GitHub and use it in different projects.


trivia

Even WebDriver executable e.g. ChromeDriver or GeckoDriver won't get initialized if they are accessed from a network path. You can find a detailed discussion in CreatePlatformSocket() returned an error: An invalid argument was supplied. (0x2726) when trying to access chromedriver through network path

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • The driver doesn't have to be in PATH ... it just has to be in PATH if it's not fully specified when setting the property. The first half of this answer is explaining something OP already knew... he called it a URL.. why are you explaining what a URL is? This question should have been dup'd to the link in your trivia section. – JeffC Feb 26 '19 at 21:22