This is because Java treats single back slash (\) as an escape character.
So you would need to use double back slash, everywhere you add some folder path. Session Not Created Exception: Expected browser binary location, but unable to find binary in default location, no ‘moz:firefox Options.binary’ capability provided, and no binary flag set on the command line But please note that this is needed only for Gecko Driver v0.16.1 or before.
UPDATE 2 [30 October, 2017]: Want to see how Firefox can be launched in headless mode?
Check this article for complete details – Firefox headless mode with Selenium UPDATE 3 [07 November, 2017]: Want to disable the low level logs that are displayed on the console?
The latest versions that we will be using in this article are – UPDATE 1 [30 April, 2017]: Do you prefer using Desired Capabilities with Firefox?
If your answer is Yes, then we have one more code snippet for you where you can add both Desired Capabilities and Firefox Options to launch Firefox with the latest version of Gecko Driver.
Illegal State Exception: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver.
The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases You will need to use Selenium Gecko Driver to remove this error. To launch Firefox with Selenium Gecko Driver, you will first need to download Gecko Driver and then set its path.
Based on whether your Firefox is 32-bit or 64-bit, you need to download the corresponding Gecko Driver exe.This code snippet is given at the end of the article (the entire process of downloading Gecko Driver and setting it up remains the same as given below). It provides lot better support for the latest browser versions.Check it out here – Setup Latest Selenium Web Driver Let us first start with the very basics – What is Gecko and Gecko Driver?Once the zip file is downloaded, unzip it to retrieve the driver – This completes the downloading process. There are 2 methods using which you can configure this driver in your project. With this method, you will have to add an additional line of code in your test case. You will need to add Property with the driver location to your code.Follow the steps given below to use this method – 1. The code to launch Firefox browser would look like this – Important Note 1: In the folder paths in the below code, we have used double backslash (\).