2015-11-19 41 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版後,問題消失了。

相關問題