2015-11-19 2 views
2

В eclipse тесты работают отлично. Я бегу мои Selenium тесты в Gradle и получаю ошибку на @AfterSuite метода в строкеSelenium + gradle + testng, UnsatisfiedLinkError on driver.quit()

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() 

Вероятно, градл взял дополнительные свойства из командной строки. Я изменил его на

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

Теперь он работает без ошибок.

+0

Это решение не работает для меня. У меня аналогичная проблема с драйвером chrome. Как вы используете эту переменную BROWSER в коде? –

+0

Я использую его для настройки браузера и создания профиля, что-то вроде 'if (BROWSER.equals (« firefox »))' –

0

У меня была такая же проблема. Проблема исчезла после обновления версии до версии 3.1.

Смежные вопросы