【发布时间】:2018-06-18 09:45:49
【问题描述】:
这是我的第一个自动化代码:
package Automationframework;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FirstTestClass {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.gecko.driver", "D:\workbox\Online Store\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.store.demoqa.com");
System.out.println("Successfully opened the website www.Store.Demoqa.com");
Thread.sleep(5000);
driver.quit();
}
}
它正在抛出错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
at Automationframework.FirstTestClass.main(FirstTestClass.java:13)**
【问题讨论】:
-
您的 url/路径中可能需要转义字符
-
在 Java 字符串文字中使用双斜杠来转义斜杠:
D:\\workbox\\Online Store\\geckodriver.exe
标签: java