Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Selenium Safari Web驱动程序不工作_Java_Selenium_Safari_Webdriver_Integration Testing - Fatal编程技术网

Java Selenium Safari Web驱动程序不工作

Java Selenium Safari Web驱动程序不工作,java,selenium,safari,webdriver,integration-testing,Java,Selenium,Safari,Webdriver,Integration Testing,除了Safari之外,我可以通过所有这些测试。如何使Safari WebDriver测试通过 测试: import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; import org.junit.Test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDrive

除了Safari之外,我可以通过所有这些测试。如何使Safari WebDriver测试通过

测试:

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;

import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.safari.SafariDriver;


public class SeleniumSetupTest
{

    @Test
    public void testThatSeleniumIsCorrectlyConfiguredWithChrome()
    {
        WebDriver chromeDriver = new ChromeDriver();
        testDriver(chromeDriver);
    }

    @Test
    public void testThatSeleniumIsCorrectlyConfiguredWithFireFox()
    {
        WebDriver firefoxDriver = new FirefoxDriver();
        testDriver(firefoxDriver);
    }

    @Test
    public void testThatSeleniumIsCorrectlyConfiguredWithSafari()
    {
        WebDriver safariDriver = new SafariDriver();
        testDriver(safariDriver);
    }

    private void testDriver(WebDriver webDriver)
    {
        webDriver.get("http://www.google.com");
        String pageTitle = webDriver.getTitle();
        assertThat(pageTitle, equalTo("Google"));
        webDriver.quit();
    }

}
Maven的输出:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.example.selenium.SeleniumSetupTest
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/jared/.m2/repository/org/slf4j/slf4j-log4j12/1.7.2/slf4j-log4j12-1.7.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/jared/.m2/repository/ch/qos/logback/logback-classic/1.0.12/logback-classic-1.0.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Starting ChromeDriver (v2.3) on port 2247
log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Sep 10, 2013 10:16:23 AM org.openqa.selenium.safari.SafariDriverServer start
INFO: Server started on port 33337
Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 10.583 sec <<< FAILURE!
testThatSeleniumIsCorrectlyConfiguredWithSafari(com.example.selenium.SeleniumSetupTest)  Time elapsed: 0.09 sec  <<< ERROR!
java.lang.NoSuchMethodError: com.google.common.io.Resources.asByteSource(Ljava/net/URL;)Lcom/google/common/io/ByteSource;
    at org.openqa.selenium.safari.SafariExtensions.getExtensionResource(SafariExtensions.java:293)
    at org.openqa.selenium.safari.SafariExtensions.install(SafariExtensions.java:217)
    at org.openqa.selenium.safari.SafariDriverCommandExecutor.start(SafariDriverCommandExecutor.java:83)
    at org.openqa.selenium.safari.SafariDriver.startClient(SafariDriver.java:115)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
    at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:101)
    at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:85)
    at com.example.selenium.SeleniumSetupTest.testThatSeleniumIsCorrectlyConfiguredWithSafari(SeleniumSetupTest.java:33)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)

Results :

Tests in error: 
  testThatSeleniumIsCorrectlyConfiguredWithSafari(com.example.selenium.SeleniumSetupTest): com.google.common.io.Resources.asByteSource(Ljava/net/URL;)Lcom/google/common/io/ByteSource;

Tests run: 3, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
-------------------------------------------------------
T T S T S
-------------------------------------------------------
运行com.example.selenium.seleniumsettest
SLF4J:类路径包含多个SLF4J绑定。
SLF4J:在[jar:file:/Users/jared/.m2/repository/org/SLF4J/SLF4J-log4j12/1.7.2/SLF4J-log4j12-1.7.2.jar!/org/SLF4J/impl/StaticLoggerBinder.class]中找到绑定
SLF4J:在[jar:file:/Users/jared/.m2/repository/ch/qos/logback/logback-classic/1.0.12/logback-classic-1.0.12.jar!/org/SLF4J/impl/StaticLoggerBinder.class]中找到绑定
SLF4J:参见http://www.slf4j.org/codes.html#multiple_bindings 我需要一个解释。
SLF4J:实际绑定的类型为[org.SLF4J.impl.Log4jLoggerFactory]
在端口2247上启动ChromeDriver(v2.3)
log4j:WARN找不到记录器(org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager)的追加器。
log4j:警告请正确初始化log4j系统。
log4j:请参阅http://logging.apache.org/log4j/1.2/faq.html#noconfig 更多信息。
2013年9月10日上午10:16:23 org.openqa.selenium.safari.SafariDriverServer启动
信息:服务器已在端口33337上启动

测试运行:3,失败:0,错误:1,跳过:0,经过的时间:10.583秒Safari驱动程序似乎正在使用。您看到的例外情况是,Safari驱动程序希望找到不同版本的Guava。在类中找不到方法
asByteSource(java.net.URL)
(这似乎反映在最新版本中)


您的类路径上很可能也会有一个较旧的Guava版本,这将使safari驱动程序无法运行,因为它需要一个较新的驱动程序。检查类路径找出加载了哪些版本,并通过删除其中一个来解决冲突。

您使用的是什么版本?您的Safari安装是否最新?我相信是的。我有版本6.0.5(8536.30.1)