2015-11-19 79 views
2

在eclipse中,测试很完美。我跑我的Selenium测试的gradle中和行混得@AfterSuite方法错误Selenium + gradle + testng,driver.quit上的UnsatisfiedLinkError()

driver.quit(); 

的build.gradle:

apply plugin: 'java' 
version = '1.1' 

repositories { 
    mavenCentral() 
    maven { url "http://repo.spring.io/libs-release" } 
} 

dependencies { 
compile "org.seleniumhq.selenium:selenium-java:2.+" 
compile "org.testng:testng:6.+" 
compile "org.mongodb:mongo-java-driver:3.1.0" 
compile "javax.mail:mail:1.4.+" 
compile "org.mindrot:jbcrypt:0.3m" 

} 

tasks.withType(Test) { 
    useTestNG() 
    systemProperties = System.getProperties() 
    ignoreFailures = true    
} 

错误文本:

java.lang.UnsatisfiedLinkError: Can't obtain updateLastError method for class com.sun.jna.Native 
at com.sun.jna.Native.initIDs(Native Method) 
at com.sun.jna.Native.<clinit>(Native.java:139) 
at org.openqa.selenium.os.Kernel32.<clinit>(Kernel32.java:34) 
at org.openqa.selenium.os.ProcessUtils.killWinProcess(ProcessUtils.java:133) 
at org.openqa.selenium.os.ProcessUtils.killProcess(ProcessUtils.java:81) 
at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.destroyHarder(UnixProcess.java:247) 
at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.access$200(UnixProcess.java:201) 
at org.openqa.selenium.os.UnixProcess.destroy(UnixProcess.java:125) 
at org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:155) 
at org.openqa.selenium.firefox.FirefoxBinary.quit(FirefoxBinary.java:259) 
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.quit(NewProfileExtensionConnection.java:204) 
at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.quit(FirefoxDriver.java:364) 
at org.openqa.selenium.firefox.FirefoxDriver.stopClient(FirefoxDriver.java:310) 
at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:519) 
at Main.DriverFactory.afterTest(DriverFactory.java:130) 

回答

0

错误是在line

systemProperties = System.getProperties() 

可能gradle从命令行接受了其他属性。我改成

systemProperties = [ 
     BROWSER: System.getProperty('BROWSER', 'firefox') 
] 

现在它的工作没有错误。

+0

此解决方案对我无效。我有类似的问题与铬驱动程序。你如何在代码中使用这个BROWSER变量? –

+0

我用它来设置浏览器并创建配置文件,如'if(BROWSER.equals(“firefox”))'' –

0

我有同样的问题。将Gradle更新至3.1版后,问题消失了。

相关问题