Facing "Unresolved compilation problem : Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )" error when trying to launch firefox from selenium. Can anyone please help me

+1 vote
package firstseleniumproject;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class openbrowser {

public static void main(String[] args) {

System.setProperty("webdriver.gecko.driver", "C:\Users\KSaraswathiChowdary\Documents\softwares\geckodriver-v0.24.0-win64.exe");

WebDriver driver = new FirefoxDriver();

driver.get("http://www.google.com");

}

}
Jul 26, 2019 in Java by anonymous

edited Jul 26, 2019 by Omkar 710 views

1 answer to this question.

+1 vote

I think the problem is with this line:

System.setProperty("webdriver.gecko.driver", "C:\Users\KSaraswathiChowdary\Documents\softwares\geckodriver-v0.24.0-win64.exe");

Backslashes (\) are used for escape sequence. Try this:

System.setProperty("webdriver.gecko.driver", "C:\\Users\\KSaraswathiChowdary\\Documents\\softwares\\geckodriver-v0.24.0-win64.exe");
answered Jul 26, 2019 by Venu
Problem is not resolved with is this line
"Facing error path does not exist"
System.setProperty("webdriver.gecko.driver", "C:\\Users\\KSaraswathiChowdary\\Documents\\softwares\\geckodriver-v0.24.0-win64.exe");

In essence, the error is telling you that somewhere, you have a backslash that does not belong, and it's escaping a character that is not in the list it's shown you.

Try using a valid escape sequence such as a backslash character.

Alternatively, you should use forward slashes, those are filesystem independent and will work whether you run your Java program on Windows, Mac, Linux or elsewhere. 

"D:/workbox/Online Store/geckodriver.exe"

Related Questions In Java

+1 vote
0 answers

getting below error when trying to conver csv file to json :The method readerFor(Class<Map>) is undefined for the type CsvMapper

PFB source code: import java.io.File; import java.lang.*; import java.util.Arrays; import java.util.List; import ...READ MORE

Dec 28, 2019 in Java by anonymous
• 160 points

closed Jan 14 by Kalgi 324 views
0 votes
2 answers

When I am running eclispe on my computer it is throwing error. How to resolve it?

If you have downloaded the 64 bit ...READ MORE

answered Dec 10, 2018 in Java by Sushmita
• 6,890 points
200 views
0 votes
1 answer

Are arrays equivalent to objects in Java ?

Yes; the Java Language Specification writes: In the Java ...READ MORE

answered May 10, 2018 in Java by Rishabh
• 3,580 points
155 views
0 votes
1 answer

Remove objects from an array in Java?

We can use external libraries: org.apache.commons.lang.ArrayUtils.remove(java.lang.Object[] array, int ...READ MORE

answered Jun 26, 2018 in Java by scarlett
• 1,280 points
158 views
0 votes
1 answer

Performance difference of if/else vs switch statement in Java

The thing you are worried about is ...READ MORE

answered Jul 26, 2018 in Java by geek.erkami
• 2,680 points
977 views
+1 vote
3 answers

What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,190 points
1,690 views
0 votes
1 answer

Getting error 404 not found when trying to download JDK

Try this command, it should work: wget --no-check-certificate ...READ MORE

answered Dec 26, 2018 in Java by Omkar
• 69,020 points
950 views
0 votes
2 answers

How can I Copy files from one directory to another in Java

Java 8 Path sourcepath = Paths.get("C:\\data\\temp\\mydir"); ...READ MORE

answered Aug 10, 2018 in Java by samarth295
• 2,190 points
812 views