对于下面的代码设置chromeoptions使用addArguments()方法给出以下错误
cannot access AbstractDriverOptions
options.addArguments("--disable-web-security");
^
class file for org.openqa.selenium.remote.AbstractDriverOptions not found
代码:
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-web-security");
options.addArguments("--headless");
options.addArguments("--window-size=2880,1800");
options.addArguments("--start-fullscreen");
options.addArguments("--disable-popup-blocking");
options.addArguments("--disable-notifications");
...
...
这段代码在旧版本的Selenium依赖项下工作正常,但现在我因为某些原因将所有依赖项升级到新版本,它不工作了
selenium 依赖性:
implementation 'org.seleniumhq.selenium:selenium-chrome-driver:4.0.0-rc-1'
implementation 'org.seleniumhq.selenium:selenium-support:4.0.0-rc-1'
build.gradle:
plugins {
id 'org.springframework.boot' version '2.5.4'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'org.ajoberstar.grgit' version '3.1.1'
id "com.gorylenko.gradle-git-properties" version "2.3.1"
}
group = 'com.leadmi'
if (project.hasProperty('appVersion')) {
version = "${appVersion}"
} else {
version = "${version}-BRANCH-${grgit.branch.current().name}-SNAPSHOT"
}
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
ext {
set('springCloudVersion', "2020.0.3")
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
implementation 'net.logstash.logback:logstash-logback-encoder:6.6'
testImplementation 'org.springdoc:springdoc-openapi-webmvc-core:1.5.10'
implementation 'com.amazonaws:aws-java-sdk-s3:1.12.60'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
implementation 'commons-io:commons-io:2.11.0'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'com.google.guava:guava:30.1.1-jre'
implementation 'io.springfox:springfox-boot-starter:3.0.0'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
testImplementation 'org.springframework.kafka:spring-kafka-test'
implementation 'org.seleniumhq.selenium:selenium-chrome-driver:4.0.0-rc-1'
implementation 'org.seleniumhq.selenium:selenium-support:4.0.0-rc-1'
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'me.xdrop:fuzzywuzzy:1.3.1'
implementation 'org.jsoup:jsoup:1.14.2'
implementation 'us.codecraft:xsoup:0.3.2'
implementation 'org.springframework.kafka:spring-kafka'
testImplementation 'org.springframework.kafka:spring-kafka-test'
implementation 'org.springframework.cloud:spring-cloud-starter-consul-config'
implementation 'org.springframework.cloud:spring-cloud-starter-consul-discovery'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
test {
useJUnitPlatform()
}
我使用的Java版本:
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~18.04-b10)
OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)
Chrome版本:
Google Chrome 93.0.4577.63
Chrome驱动程序版本:
93.0.4577.15
2条答案
按热度按时间dw1jzc5e1#
你错过了下面的依赖关系
正如官方文档中所述,通常我们可以使用
selenium-java
依赖项代替
参考:
Unable to set maven dependencies for RemoteWebDriver
kh212irz2#
addArguments方法不是将字符串作为参数,而是将参数作为参数列表接受。