在eclipse中,测试工作得很完美。我正在gradle中运行我的Selenium测试,并在行
中的@AfterSuite
方法上出错
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 :(得分:0)
错误在行
systemProperties = System.getProperties()
可能gradle从命令行获取了其他属性。我把它改成了
systemProperties = [
BROWSER: System.getProperty('BROWSER', 'firefox')
]
现在它正常运行。
答案 1 :(得分:0)
我有同样的问题。更新gradle到3.1版本后,问题就消失了。