我正在运行以下测试代码,但我得到了错误:**SLF4J:加载类"失败;org.slf4j.impl.StaticLoggerBinder"。SLF4J:默认为无操作(NOP(记录器实现SLF4J:请参阅http://www.slf4j.org/codes.html#StaticLoggerBinder了解更多详细信息。C: \geccodriver.exe:错误:找到参数"--websocket端口",该参数不是预期的,或在此上下文中无效
用法:geckodriver.exe--端口
有关更多信息,请尝试帮助
线程中的异常";主";org.openqa.selenium.SessionNotCreatedException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败。网址:org.openqa.selene.remote.RemoteWebDriver.exexecute(RemoteWebDriver.java:565(网址:org.openqa.selene.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242(网址:org.openqa.selene.remote.RemoteWebDriver.(RemoteWebDriver.java:157(网址:org.openqa.seselenium.firefox.FirefoxDriver。(FirefoxDriver.java:110(网址:org.openqa.seselenium.firefox.FirefoxDriver。(FirefoxDriver.java:98(网址:org.openqa.seselenium.firefox.FirefoxDriver。(FirefoxDriver.java:94(在newpackage。Login.main(Login.java:17(由以下原因引起:org.openqa.selenium.WebDriverException:驱动程序服务器进程过早终止。内部版本信息:版本:"4.4.0",修订版:"e5c75ed026a",os.arch:"amd64",os.version:"10.0",java.version:"1.8.0_281"驱动程序信息:Driver.version:FirefoxDriver网址:org.openqa.selene.remote.service.DriverService.start(DriverService.java:226(网址:org.openqa.selene.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:98(网址:org.openqa.selene.remote.RemoteWebDriver.exexecute(RemoteWebDriver.java:547(…还有6个**
package neoproject;
import org.openqa.selenium.WebDriver;
//import org.openqa.selenium.firefox.FirefoxDriver;
//comment the above line and uncomment below line to use Chrome
import org.openqa.selenium.chrome.ChromeDriver;
public class PG1 {
public static void main(String[] args) {
// declaration and instantiation of objects/variables
//System.setProperty("webdriver.gecko.driver","C:\geckodriver.exe");
//WebDriver driver = new FirefoxDriver();
//comment the above 2 lines and uncomment below 2 lines to use Chrome
System.setProperty("webdriver.chrome.driver","G:\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String baseUrl = "http://demo.guru99.com/test/newtours/";
String expectedTitle = "Welcome: Mercury Tours";
String actualTitle = "";
// launch Fire fox and direct it to the Base URL
driver.get(baseUrl);
// get the actual value of the title
actualTitle = driver.getTitle();
/*
* compare the actual title of the page with the expected one and print
* the result as "Passed" or "Failed"
*/
if (actualTitle.contentEquals(expectedTitle)){
System.out.println("Test Passed!");
} else {
System.out.println("Test Failed");
}
//close Fire fox
driver.close();
}
}
public class MyClass {
}
提前感谢您的支持。
检查您的selenium java版本以及浏览器版本
一旦删除seleniumJava依赖项并在pom.xml 中添加新的seleniumjava依赖项