我正在尝试在mac机器中打开firefox浏览器。 因为我正在使用最新的selenium jar文件,所以为了打开Firefox浏览器,我使用geckodriver但是无法启动浏览器。
以下是我用于使用geckodriver打开浏览器的代码:
public class Apache_POI_TC {
private static WebDriver driver = null;
public static void main(String[]arg) throws Exception{
//This is to open the Excel file. Excel path, file name and the sheet name are parameters to this method
ExcelUtils.setExcelFile(Constant.Path_TestData+ Constant.File_TestData, "Sheet1");
System.setProperty("webdriver.gecko.driver", "/Users/ileadsynapse/Desktop/CT/geckodriver");
DesiredCapabilities capabilities= DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
driver = new FirefoxDriver(capabilities);
driver.get("http://www.store.demoqa.com");
SignIn_Action.Execution(driver);
System.out.println("Login successfully.");
Home_Page.lnk_LogOut(driver).click();
driver.quit();
//This is to send the PASS value to the Excel sheet in the result column.
ExcelUtils.setCellData("Pass", 1, 3);
}
}
错误
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/Logger
at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
at org.apache.logging.log4j.jcl.LogAdapter.newLogger(LogAdapter.java:34)
at org.apache.logging.log4j.jcl.LogAdapter.newLogger(LogAdapter.java:30)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:40)
at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:55)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
at org.apache.http.conn.ssl.AbstractVerifier.<init>(AbstractVerifier.java:61)
at org.apache.http.conn.ssl.AllowAllHostnameVerifier.<init>(AllowAllHostnameVerifier.java:44)
at org.apache.http.conn.ssl.AllowAllHostnameVerifier.<clinit>(AllowAllHostnameVerifier.java:46)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:146)
at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:71)
at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:57)
at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:60)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:247)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.<init>(ApacheHttpClient.java:224)
at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:93)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:72)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:59)
at org.openqa.selenium.remote.service.DriverCommandExecutor.<init>(DriverCommandExecutor.java:49)
at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:207)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:108)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:137)
at automationFramework.Apache_POI_TC.main(Apache_POI_TC.java:31)
Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 24 more
任何人都可以帮我解决问题。在此先感谢。
答案 0 :(得分:0)
在构建路径中配置以下jar后,我在mac机器中使用geckodriver打开Firefox浏览器的问题得到解决:
log4j-1.2.16.jar
slf4j-api-1.7.6.jar
slf4j-simple-1.7.6.jar
xuggle-xuggler-5.4.jar