[英]Cannot refresh-dependencies for Selenium with Gradle
I don't understand why Gradle isn't downloading Selenium, even with refresh-dependencies
, given that Hibernate
downloads fine . 考虑到Hibernate
可以正常下载,我不明白Gradle为什么不下载Selenium,即使具有refresh-dependencies
。 Selenium is using the mavenCentral
repo, just like Hibernate
: Selenium正在使用mavenCentral
库,就像Hibernate
一样:
thufir@mordor:~/NetBeansProjects/sel$
thufir@mordor:~/NetBeansProjects/sel$ gradle clean run --refresh-dependencies
:clean
:compileJava
Download https://repo1.maven.org/maven2/org/hibernate/hibernate-core/3.6.7.Final/hibernate-core-3.6.7.Final.pom
Download https://repo1.maven.org/maven2/org/hibernate/hibernate-parent/3.6.7.Final/hibernate-parent-3.6.7.Final.pom
Download https://jitpack.io/com/github/THUFIR/hello_api/master-SNAPSHOT/hello_api-master-1-gef696be-2.pom
Download https://repo1.maven.org/maven2/antlr/antlr/2.7.6/antlr-2.7.6.pom
Download https://repo1.maven.org/maven2/commons-collections/commons-collections/3.1/commons-collections-3.1.pom
Download https://repo1.maven.org/maven2/dom4j/dom4j/1.6.1/dom4j-1.6.1.pom
Download https://repo1.maven.org/maven2/org/hibernate/hibernate-commons-annotations/3.2.0.Final/hibernate-commons-annotations-3.2.0.Final.pom
Download https://repo1.maven.org/maven2/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final.pom
Download https://repo1.maven.org/maven2/javax/transaction/jta/1.1/jta-1.1.pom
Download https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.pom
Download https://repo1.maven.org/maven2/org/slf4j/slf4j-parent/1.6.1/slf4j-parent-1.6.1.pom
Download https://repo1.maven.org/maven2/org/hibernate/hibernate-core/3.6.7.Final/hibernate-core-3.6.7.Final.jar
Download https://repo1.maven.org/maven2/antlr/antlr/2.7.6/antlr-2.7.6.jar
Download https://repo1.maven.org/maven2/commons-collections/commons-collections/3.1/commons-collections-3.1.jar
Download https://repo1.maven.org/maven2/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
Download https://repo1.maven.org/maven2/org/hibernate/hibernate-commons-annotations/3.2.0.Final/hibernate-commons-annotations-3.2.0.Final.jar
Download https://repo1.maven.org/maven2/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final.jar
Download https://repo1.maven.org/maven2/javax/transaction/jta/1.1/jta-1.1.jar
Download https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar
/home/thufir/NetBeansProjects/sel/src/main/java/net/bounceme/mordor/javascript/Main.java:25: error: no suitable constructor found for FirefoxDriver(URL)
driver = new org.openqa.selenium.firefox.FirefoxDriver(url);
^
constructor FirefoxDriver.FirefoxDriver(FirefoxProfile) is not applicable
(argument mismatch; URL cannot be converted to FirefoxProfile)
constructor FirefoxDriver.FirefoxDriver(Capabilities) is not applicable
(argument mismatch; URL cannot be converted to Capabilities)
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 15.867 secs
thufir@mordor:~/NetBeansProjects/sel$
build file: 构建文件:
apply plugin: 'java'
apply plugin: 'application'
mainClassName = 'net.bounceme.mordor.javascript.Main'
//version = 'dev'
//group = 'com.some.project'
description = 'hello world KISS'
clean{
delete "javascript"
}
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
if (!hasProperty(mainClassName)) {
ext.mainClass = mainClassName
}
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.+'
compile 'com.github.THUFIR:hello_api:master-SNAPSHOT'
}
jar.doFirst
{
def manifestClasspath = configurations.runtime.collect { it.name }
manifestClasspath = manifestClasspath.unique().join(" ")
println (manifestClasspath)
manifest.attributes.put("Main-Class", mainClassName)
manifest.attributes.put("Class-Path", manifestClasspath)
}
/home/thufir/NetBeansProjects/sel/src/main/java/net/bounceme/mordor/javascript/Main.java:25: error: no suitable constructor found for FirefoxDriver(URL)
driver = new org.openqa.selenium.firefox.FirefoxDriver(url);
^
constructor FirefoxDriver.FirefoxDriver(FirefoxProfile) is not applicable
(argument mismatch; URL cannot be converted to FirefoxProfile)
constructor FirefoxDriver.FirefoxDriver(Capabilities) is not applicable
(argument mismatch; URL cannot be converted to Capabilities)
Here is argument mismatch problem. 这是参数不匹配的问题。
From your build.xml
file, 在您的build.xml
文件中,
mainClassName = 'net.bounceme.mordor.javascript.Main'
which executes Main.java
class. 它执行Main.java
类。
In Main.java
class, There is a declaration/object creation driver = new org.openqa.selenium.firefox.FirefoxDriver(url);
在Main.java
类中,有一个声明/对象创建driver = new org.openqa.selenium.firefox.FirefoxDriver(url);
which creates the error. 这会导致错误。
Here Java compiler cannot construct a FirefoxDriver(URL)
object, because your call to the constructor does not match with it's any known constructor. 在这里,Java编译器无法构造FirefoxDriver(URL)
对象,因为您对构造函数的调用与它的任何已知构造函数都不匹配。
Specifically, the compiler found the constructor: 具体来说,编译器找到了构造函数:
FirefoxDriver.FirefoxDriver()
but your call looks like below, which is mismatching: 但您的通话如下所示,这不匹配:
new org.openqa.selenium.firefox.FirefoxDriver(url); // remove url from this section.
Change your code in Main.java
in line number 25
在第25
行的Main.java
中更改代码
driver = new org.openqa.selenium.firefox.FirefoxDriver();
Hope, it will solve your issue. 希望能解决您的问题。
Related Link: 相关链接:
Banging away at the keyboard like a monkey, got gradle to download the Selenium dependency. 像猴子一样敲着键盘,摇摇晃晃地下载了Selenium依赖项。 How and why, don't know as of yet, I'll have to look for differences. 如何以及为什么,到目前为止还不知道,我必须寻找差异。
Kludge, which executes: Kludge,它执行:
thufir@mordor:~/NetBeansProjects/selenium$
thufir@mordor:~/NetBeansProjects/selenium$ gradle clean build --refresh-dependencies
:clean
:compileJava
Download https://jitpack.io/com/github/THUFIR/hello_api/master-SNAPSHOT/hello_api-master-1-gef696be-2.pom
:processResources UP-TO-DATE
:classes
:jar
hibernate-core-3.6.7.Final.jar selenium-java-2.53.0.jar hello_api-master-SNAPSHOT.jar jna-4.1.0.jar antlr-2.7.6.jar jna-platform-4.1.0.jar commons-collections-3.1.jar netty-3.5.7.Final.jar dom4j-1.6.1.jar hibernate-commons-annotations-3.2.0.Final.jar cglib-nodep-2.1_3.jar hibernate-jpa-2.0-api-1.0.1.Final.jar gson-2.3.1.jar jta-1.1.jar slf4j-api-1.6.1.jar selenium-api-2.53.0.jar httpclient-4.5.1.jar selenium-chrome-driver-2.53.0.jar selenium-edge-driver-2.53.0.jar guava-19.0.jar selenium-firefox-driver-2.53.0.jar selenium-ie-driver-2.53.0.jar selenium-safari-driver-2.53.0.jar selenium-support-2.53.0.jar selenium-leg-rc-2.53.0.jar httpcore-4.4.3.jar selenium-remote-driver-2.53.0.jar commons-logging-1.2.jar commons-codec-1.9.jar commons-io-2.4.jar commons-exec-1.3.jar
:startScripts
:distTar
:distZip
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
BUILD SUCCESSFUL
Total time: 14.021 secs
thufir@mordor:~/NetBeansProjects/selenium$
thufir@mordor:~/NetBeansProjects/selenium$
thufir@mordor:~/NetBeansProjects/selenium$ cat build.gradle
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'maven'
mainClassName = 'net.bounceme.mordor.hello.client.HelloClient'
//version = 'dev'
//group = 'com.some.project'
description = 'hello world KISS'
clean{
delete "hello_client"
}
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
if (!hasProperty(mainClassName)) {
ext.mainClass = mainClassName
}
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.+'
compile 'com.github.THUFIR:hello_api:master-SNAPSHOT'
}
jar.doFirst
{
def manifestClasspath = configurations.runtime.collect { it.name }
manifestClasspath = manifestClasspath.unique().join(" ")
println (manifestClasspath)
manifest.attributes.put("Main-Class", mainClassName)
manifest.attributes.put("Class-Path", manifestClasspath)
}
thufir@mordor:~/NetBeansProjects/selenium$
thufir@mordor:~/NetBeansProjects/selenium$ gradle run
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:run
hello world
BUILD SUCCESSFUL
Total time: 6.15 secs
thufir@mordor:~/NetBeansProjects/selenium$
thufir@mordor:~/NetBeansProjects/selenium$ cat src/main/java/net/bounceme/mordor/hello/client/HelloClient.java
package net.bounceme.mordor.hello.client;
import static java.lang.System.out;
import net.bounceme.mordor.hello.library.HelloLibrary;
public class HelloClient {
private org.openqa.selenium.WebDriver driver = new org.openqa.selenium.firefox.FirefoxDriver();
public static void main(String... args) {
new HelloClient().runLibrary(args);
}
private void runLibrary(String... args) {
HelloLibrary library = new HelloLibrary();
out.println(library.hello(args));
}
}
thufir@mordor:~/NetBeansProjects/selenium$
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.