selenide.open attempt throws NoSuchMethodError - selenium

I'm trying to simply navigate to google page:
String url = "https://www.google.com";
Selenide.open(url);
and the exact exception thrown is:
java.util.stream.Collector com.google.common.collect.ImmutableList.toImmutableList()'
java.lang.NoSuchMethodError: 'java.util.stream.Collector com.google.common.collect.ImmutableList.toImmutableList()'
at org.openqa.selenium.chrome.ChromeOptions.asMap(ChromeOptions.java:292)
at org.openqa.selenium.MutableCapabilities.merge(MutableCapabilities.java:73)
at com.codeborne.selenide.webdriver.MergeableCapabilities.<init>(MergeableCapabilities.java:19)
at ...
I use Chrome 86.0.4240.111 (64-bit) and selenide 5.15.1

The point is that selenide is not compatible with test-ng, at least with this version mentioned in gradle
testCompile group: 'org.testng', name: 'testng', version: '7.3.0'
compile group: 'com.codeborne', name: 'selenide', version: '5.15.1'
Removing test-ng solved the problem

Related

Gradle selenium(any) dependencies are not downloading

After creating new java gradle project added following dependencies in build file.
enter image description here
dependencies {
// Use JUnit Jupiter for testing.
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2'
// This dependency is used by the application.
implementation 'com.google.guava:guava:30.1.1-jre'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.3.0'
// https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager
implementation group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '5.3.0'
// https://mvnrepository.com/artifact/org.testng/testng
testImplementation group: 'org.testng', name: 'testng', version: '7.6.1'
// https://mvnrepository.com/artifact/org.apache.poi/poi
implementation group: 'org.apache.poi', name: 'poi', version: '5.2.2'
// https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api
implementation("javax.annotation:javax.annotation-api:1.3.2")
}
Then following popup appeared on vs code.
"Do you want to synchronize the Java classpath/configuration" once and for all? with yes/always/never option
I tried selecting each option in new project. Still after doing gradle build none of dependency downloaded
So if I am writing WebDriver or WebDriverManager I am not getting import option in quick fix

Selenium4+Junit5 : Infinite browsers are launching while running scripts in Parallel with Selenium 4

I have well configure and designed framework using webdrivermanager = '5.0.3'( Selenium 3.141.5,) + Junit 5 + junit-platform.properties file to run the test scripts in parallel, which running seamlessly without any issues. I am able to run scripts based on tags and based on package.
Now I upgraded the selenium version to 4.1.2, when I run individual script it is perfectly fine but when run the scripts in parallel infinite browsers are launching even though thread count is restricted to 5 in junit-platform.properties file.
junit.jupiter.execution.parallel.enabled=false
junit.jupiter.execution.parallel.mode.default=same_thread
junit.jupiter.execution.parallel.mode.classes.default=concurrent
junit.jupiter.execution.parallel.config.strategy=fixed
junit.jupiter.execution.parallel.config.fixed.parallelism=5
I am using below mentioned dependencies in build gradle file.
repositories {
jcenter()
mavenCentral()
}
ext {
// selenium = '3.141.59'
webdrivermanager = '5.0.3'
// junitJupiterVersion = '5.8.2'
selenium = '4.1.2'
seleniumJupiterVersion = '4.0.1'
junitJupiterVersion = '5.7.0'
}
dependencies {
compile("org.junit.jupiter:junit-jupiter:${junitJupiterVersion}")
compile("org.seleniumhq.selenium:selenium-java:${selenium}")
// compile("io.github.bonigarcia:selenium-jupiter:${seleniumJupiterVersion}")
// compile("org.seleniumhq.selenium:selenium-java:${selenium}")
// compile("io.github.bonigarcia:webdrivermanager:${webdrivermanager}")
// testImplementation "org.seleniumhq.selenium:selenium-chrome-driver:${selenium}"
// testImplementation "org.seleniumhq.selenium:selenium-firefox-driver:${selenium}"
// testImplementation "org.seleniumhq.selenium:selenium-ie-driver:${selenium}"
// testImplementation "org.seleniumhq.selenium:selenium-edge-driver:${selenium}"
// testImplementation "org.seleniumhq.selenium:selenium-safari-driver:${selenium}"
// testImplementation "org.seleniumhq.selenium:selenium-remote-driver:${selenium}"
// testImplementation "org.seleniumhq.selenium:selenium-support:${selenium}"
// testImplementation('org.junit.jupiter:junit-jupiter:5.5.1')
// testImplementation 'org.hamcrest:hamcrest:2.1'
// testImplementation 'org.hamcrest:hamcrest-library:2.1'
// testCompile("org.junit.jupiter:junit-jupiter-api:5.6.2")
// testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.6.2'
// testRuntime("org.junit.platform:junit-platform-launcher:1.4.2")
// testCompile('io.github.bonigarcia:selenium-jupiter:4.0.1')
compile group: 'io.qameta.allure', name: 'allure-junit5', version: '2.11.0'
compile group: 'org.apache.pdfbox', name: 'pdfbox', version: '2.0.16'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.1'
// implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.17.1'
compile group: 'io.qameta.allure', name: 'allure-gradle', version: '2.7.0'
compile 'org.apache.maven.plugins:maven-surefire-plugin:2.21.0'
// compile('com.assertthat:selenium-shutterbug:1.5')
compile 'org.slf4j:slf4j-nop:1.7.25'
implementation group: 'javax.mail', name: 'mail', version: '1.4.7'
// implementation group: 'javax.mail', name: 'javax.mail-api', version: '1.6.2'
// runtimeClasspath group: 'javax.mail', name: 'javax.mail-api', version: '1.6.2'
// compile group: 'net.lightbody.bmp', name: 'browsermob-core', version: '2.1.4'
// compile group: 'org.postgresql', name: 'postgresql', version: '42.2.14'
compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.12.4'
compile group: 'ru.yandex.qatools.ashot', name: 'ashot', version: '1.5.4'
// implementation group: 'org.json', name: 'json', version: '20201115'
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
// testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.7.2'
// testImplementation group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.7.2'
// testImplementation group: 'org.junit.platform', name: 'junit-platform-surefire-provider', version: '1.3.2'
}
Project component : Selenium 4 +Junit5 +junit-platform properties file
Any help to resolve this issue is highly appreciated.
Sorry, if the question is still relevant, of course.
First, you may just marked all your test classes with #ResourceLock("SYSTEM_OUT") annotation. see details here and below about Syncronization.
However this may not help. Then you may additionally implement ParrallelExecutionConfiguration and ParallelExecutionConfigurationStrategy and write this implementation in a junit-platform.properties file e.g.
junit.juipiter.execution.parallel.config.custom.class=base.ParallelStrategy
where "base" - package and "ParallelStrategy" - the implementation of the above interfaces (I just return numbers of thread values).
Also you have to state custom strategy explicitly:
junit.juipiter.execution.parallel.config.strategy=custom
Why it worked with Selenium3+, but stopped with the fourth - I don’t know. But these steps solved the same problem for me as yours.
There's a few components which might be causing this.
JUnit issue 'Parallelism value ignored for the fixed strategy' #2273 describes how the ForkJoinPool used will actually grow if threads are blocked
Selenium issue 'Can no longer limit the number of parallel sessions from JUnit 5 #9359' describes how the above issue impacts Selenium versions 4.0.0-alpha-4 and up.
Both issues suggest defining a custom strategy which limits the MaxPoolSize. This works, but only on JDK9 and up. The ForkJoinPool created in ForkJoinPoolHierarchicalTestExecutorService is different between JDK8 and JDK9+, with only the latter using the strategy MaxPoolSize.
So if you're on JDK8, I think the only option is to use ResourceLocks. Otherwise, define a custom strategy.
See my SO post maven-failsafe-plugin not honoring fixed parallelism in JUnit5 for pretty much the same issue.

Build Intellij plugin in IDEA 2019.1 & 2020.3

Building for IDEA 2019.1 works like a charm! I thought that building for 2020.3 would be just a matter of pointing to 2020.3 installation folder and that's it, but it is not being even close to it.
That's my gradle.build
group 'com.test.plugin'
version '1.0-SNAPSHOT'
buildscript {
repositories {
maven {
url "https://mydomain/repository/public-maven/"
}
}
dependencies {
classpath group: 'org.jetbrains.intellij.plugins', name: 'gradle-intellij-plugin', version: '0.6.5'
}
}
apply plugin: 'java'
apply plugin: 'org.jetbrains.intellij'
intellij {
localPath 'C:/Program Files/JetBrains/IntelliJ IDEA 2019.1.3'
}
sourceCompatibility = 1.8
repositories {
maven {
url "https://mydomain/repository/public-maven/"
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
runtime group: 'com.google.guava', name: 'guava', version: '23.0'
runtime group: 'org.apache.commons', name: 'commons-lang3', version: '3.11'
}
It is important to mention that since I'm working behind a restricted company proxy I can't just set the Intellij version in order to get the necessary distribution files to the build (Intellij.localPath)
Building it on IDEA 2019.1, JDK 1.8 works fine. In order to build the same code for a IDEA 2020.3 I just replaced the Intellij distribution path:
intellij {
//localPath 'C:/Program Files/JetBrains/IntelliJ IDEA 2019.1.3'
localPath 'C:/Dev/apps/ideaIU-2020.3'
}
Trying to build it now immediately throws it:
error: cannot access AnAction
bad class file: C:\Dev\apps\ideaIU-2020.3\lib\platform-api.jar(com/intellij/openapi/actionSystem/AnAction.class)
class file has wrong version 55.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
What I understand form it is that AnAction class was built using Java 11. So, I replaced the project JDK to use also JDK11 and from that moment I started facing compilation errors, like com.intellij.psi.PsiJavaFile cannot be found.
I might be missing some conceptual point here.
it turns out there was a missing plugin dependency.
this line was not being effective to resolve such dependency. In order to fix that I had to remove apply plugin: 'java' and set intellij.plugin
intellij {
localPath 'C:/Dev/apps/ideaIU-2020.3'
plugin = ['com.intellij.java']
}

Exception in thread "main" cucumber.runtime.CucumberException: Unrecognized plugin: org.jetbrains.plugins.cucumber.java.run.CucumberJvm3SMFormatter

Error while running cucumber feature / scenario from intellij .
I have latest version of cucumber of java plugin installed (v183.4284.148)
Exception in thread "main" cucumber.runtime.CucumberException: Unrecognized plugin: org.jetbrains.plugins.cucumber.java.run.CucumberJvm3SMFormatter
at cucumber.runtime.RuntimeOptions.addPluginName(RuntimeOptions.java:171)
at cucumber.runtime.RuntimeOptions.parse(RuntimeOptions.java:122)
at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:84)
at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:77)
at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:69)
at cucumber.api.cli.Main.run(Main.java:31)
at cucumber.api.cli.Main.main(Main.java:18)
Process finished with exit code 1
Following is my dependencies in build.gradle
dependencies {
compile group: 'org.glassfish.jersey.core', name: 'jersey-client', version: '2.27'
compile group: 'org.glassfish', name: 'javax.json', version: '1.1.2'
compile group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: '2.27'
compile group: 'com.jayway.jsonpath', name: 'json-path-assert', version: '2.4.0'
compile group: 'com.google.guava', name: 'guava', version: '25.0-jre'
compile group: 'io.cucumber', name: 'cucumber-java8', version: '4.2.0'
compile group: 'io.cucumber', name: 'cucumber-junit', version: '4.2.0'
compile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
compile group: 'uk.sponte.automation', name: 'selenium-pom', version: '3.0.12'
compile group: 'org.reflections', name: 'reflections', version: '0.9.11'
compile group: 'io.cucumber', name: 'cucumber-picocontainer', version: '4.2.0'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.25'
compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.6.3'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.+'
testCompile group: 'org.awaitility', name: 'awaitility', version: '3.1.2'
}
This was working fine until 20 Dec 2018 .Tried reinstalling intellij ,reinstalling cucumber for java plugins ,using different versions of cucumber-java8 and cucumber-junit ,Nothing helped

Cannot change dependencies of configuration

After I added copyBootstrap to build.gradle I am getting the next error when try to run the build task:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project '.
Cannot change dependencies of configuration ':providedCompile' after it has been included in dependency resolution.
How could this issue be solved? I have searched on Internet but no solutions were found. I got the copyBootstrap task from this link. Their goal is to extract all content from org.webjars group jars to a specific path.
I am using Gradle 3.2 and Intellij IDEA 2016.2.5
//group 'org'
//version '1.0-SNAPSHOT'
task wrapper(type: Wrapper) {
gradleVersion = '3.2'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.akhikhl.gretty:gretty:1.4.0'
}
}
repositories {
mavenCentral()
jcenter()
}
//apply plugin: 'java'
//apply plugin: 'eclipse-wtp'
//apply from: 'https://raw.github.com/akhikhl/gretty/master/pluginScripts/gretty.plugin'
apply plugin: 'war'
apply plugin: 'org.akhikhl.gretty'
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
//compile group: 'org.akhikhl.gretty', name: 'gretty', version: '1.4.0'
// ********************************************************************************************************
// SPRING FRAMEWORK, ORM Y H2DB
// ********************************************************************************************************
compile group: 'org.springframework', name: 'spring-webmvc', version: '4.3.4.RELEASE'
compile group: 'org.springframework', name: 'spring-orm', version: '4.3.4.RELEASE'
compile group: 'org.springframework', name: 'spring-jdbc', version: '4.3.4.RELEASE'
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.3.Final'
// ********************************************************************************************************
// JACKSON DATABIND
// ********************************************************************************************************
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.4'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.4'
// ********************************************************************************************************
// THYMELEAF
// ********************************************************************************************************
compile group: 'org.thymeleaf', name: 'thymeleaf-spring4', version: '3.0.2.RELEASE'
// ********************************************************************************************************
// SERVLET
// ********************************************************************************************************
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
// ********************************************************************************************************
// MYSQL CONNECTOR
// ********************************************************************************************************
//compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.5' issues with time zone
compile 'mysql:mysql-connector-java:5.1.6'
// ********************************************************************************************************
// WEB RESOURCES
// ********************************************************************************************************
compile group: 'org.webjars', name: 'angularjs', version: '1.5.8'
compile group: 'org.webjars', name: 'jquery', version: '2.1.4'
compile group: 'org.webjars', name: 'bootstrap', version: '3.3.7'
compile group: 'org.webjars', name: 'jquery-ui', version: '1.12.1'
compile group: 'org.webjars', name: 'modernizr', version: '2.8.3'
// ********************************************************************************************************
// JUNIT AND SPRING TEST
// ********************************************************************************************************
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.springframework', name: 'spring-test', version: '4.3.4.RELEASE'
// ********************************************************************************************************
// GOOGLE DRIVE API
// ********************************************************************************************************
compile group: 'com.google.api-client', name: 'google-api-client', version: '1.22.0'
compile group: 'com.google.apis', name: 'google-api-services-drive', version: 'v2-rev245-1.22.0'
compile group: 'com.google.api-client', name: 'google-api-client-java6', version: '1.22.0'
compile group: 'com.google.oauth-client', name: 'google-oauth-client-jetty', version: '1.22.0'
// ********************************************************************************************************
// DROPBOX API
// ********************************************************************************************************
compile group: 'com.dropbox.core', name: 'dropbox-core-sdk', version: '1.8.2'
// ********************************************************************************************************
// TWITTER API
// ********************************************************************************************************
compile group: 'org.twitter4j', name: 'twitter4j-core', version: '4.0.5'
// compile group: 'org.slf4j', name: 'slf4j-mylearn.api', version: '1.7.21'
// compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.21'
// compile files("twitter/main/webapp/") // add this path as a classpath
}
task copyBootstrap(type: Copy) {
into "$buildDir/static_resources"
configurations.compile
.files({ it.group.equals("org.webjars")})
.each {
from zipTree(it)
}
}
//build.dependsOn(copyBootstrap)
task copyToLib2(type: Copy) {
into "$buildDir/output/libs"
from configurations.runtime
}
war {
archiveName = 'ROOT.war'
destinationDir = file('webapps')
}
// ********************************************************************************************************
// GRETTY SETTINGS
// ********************************************************************************************************
/* Change context path (base url). otherwise defaults to name of project */
gretty {
port = 8081
contextPath = ''
}
This problem seems to be related to the org.akhikhl.gretty plugin you are trying to use. If I try to build a project using the above gradle file I get the following output:
C:\ws\PLAYGROUND\test123>gradle wrapper --stacktrace
Changed dependencies of configuration ':providedCompile' after it has been included in dependency resolution. This behaviour has been deprecated and is cheduled to be removed in Gradle 3.0.
Changed dependencies of parent of configuration ':compile' after it has been resolved. This behaviour has been deprecated and is scheduled to be removed in Gradle 3.0
Changed strategy of configuration ':compile' after it has been resolved. This behaviour has been deprecated and is scheduled to be removed in Gradle 3.0
Changed dependencies of configuration ':grettyProvidedCompile' after it has been included in dependency resolution. This behaviour has been deprecated and is scheduled to be removed in Gradle 3.0.
⋮
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'test123'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)
⋮
Caused by: org.gradle.api.InvalidUserDataException: Cannot change dependencies of configuration ':compile' after it has been resolved.
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.validateMutation(DefaultConfiguration.java:578)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$2.run(DefaultConfiguration.java:137)
⋮
at org.akhikhl.gretty.GrettyPlugin$_addDependencies_closure11.doCall(GrettyPlugin.groovy:130)
⋮
That is the gretty plugin seems to use functionality that has been removed with gradle 3.0
There is issue #306 that has been reported a short time ago which describes pretty much your problem.
Given the number of open issues for such a small project and the lack of activity on the issues, I don't think this plugin is much of a help and you will probably be better off using something different.