Selenium remote driver issue with HtmlUnit driver - selenium

[i'm seeing the issue with Selenium remote driver when I'm executing the script with Htmlunit driver.
Note 1:- Same script works without any issue when I'm running with Firefox driver.]
Note 2: My browser had security authentication process for whatever the site i open, Not sure if that have ant role in this.
I have observed the selenium remote driver under maven shows with little different icon in left pane.
I feel its jar file loading issue.
I tried to put the selenium remote driver manually into .m2 repository.
1
Error message:-
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException
at TestPackage.titleNUrlCheckingTest.main(titleNUrlCheckingTest.java:16)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.SessionNotFoundException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
[enter image description here][2]

You need to use latest version, note the change of artifactId from old versions.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.26</version>
</dependency>
which depends on
selenium-api 3.3.1
Update:
Your pom.xml works with simple test case of HtmlUnitDriver, but there is a potential conflict of versions, you should exclude HtmlUnitDriver 2.24 from selenium-java 3.3.1:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.3.1</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
Also, try to remove all selenium dependencies, and have only htmlunit-driver, all needed dependencies are automatically handled by maven.

Please update your POM XML file with latest version of htmlunit dependency
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.32.1</version>
</dependency>
and remove if you have something like
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.52.0</version>
</dependency>
and update project. This should resolve your exception issue.
Reference: https://github.com/SeleniumHQ/selenium/issues/4930

Related

Azure Keyvault library to Atlassian Confluence plugin pom.xml

I am trying to combine these 2 tutorials - Confluence Hello World Macro & Azure keyvault quick start:
https://developer.atlassian.com/server/framework/atlassian-sdk/create-a-confluence-hello-world-macro/
https://learn.microsoft.com/en-us/azure/key-vault/secrets/quick-create-java?tabs=azure-cli
After having added the 2 Azure dependencies to the pom.xml of the maven project and running atlas-mvn clean package I receive an error message about 3 banned dependencies.
I looked for the newest Azure packages at the maven portal. Then it was reduced to one.
Found Banned Dependency: org.slf4j:slf4j-api:jar:1.7.25
Then I added added exclusions to the dependency section:
This resulted that the build ran successfully, however, the Confluence plugin produces a runtime error:
java.lang.NoClassDefFoundError
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/Logger
at com.azure.security.keyvault.secrets.SecretClientBuilder.(SecretClientBuilder.java:110)
Can you please help, how can I achieve this?
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-security-keyvault-secrets</artifactId>
<version>4.3.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.4.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
error: java.lang.NoClassDefFoundError Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/Logger at com.azure.security.keyvault.secrets.SecretClientBuilder.(SecretClientBuilder.java:110)
The above error indicates that JVM is not able to found org/slf4j/Logger class in your application's path.The simplest reason for this error is the missing Slf4j.jar file.
If the problem is caused due to the missing slf4j.jar file then you can fix it by adding a relevant version of slf4j.jar into your path.
Use the latest version of the jar in which version of the JAR file you should add will depend upon the application.
In Maven , you can also add the following dependency in your pom.xml file to download sl4j.jar
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
Reference:
java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory - Stack Overflow

I am trying to setup selenium with maven but am getting this error when declaring driver

I am trying to set up a selenium project with the maven build tool.
I have defined the dependencies but am still getting this error in the script.
Your screenshot suggests that you don't have org.openqa.selenium. As this is part of Selenium Java, you will need to include this dependency in your pom file:
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.11.0</version>
</dependency>
https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java/3.11.0

Selenium-Java:Browsermob Proxyy- NoClassDefFoundError

I updated POM.xml with latest selenium-java dependency and Browsermob proxy.
Java Code:
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
driver.quit();
POM.xml looks like,
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>net.lightbody.bmp</groupId>
<artifactId>browsermob-proxy</artifactId>
<version>2.0-beta-8</version>
</dependency>
While I run the automation script, getting the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/HasInputDevices
The script runs fine , after removing Browsermob proxy dependency. ( But I need Browsermob proxy to capture network data).
Looks like the Browsermob proxy has a dependency selenium-api-2.*, I assume that is outdated and causing this problem.
Any help would be greatly appreciated.
It looks like you're using a very old version of BrowserMob Proxy, which probably isn't compatible with the latest versions of Selenium.You can find the latest version of BMP on its github page.
For example, the current version of BMP is 2.1.2, so you'd want to include this in your pom file:
<dependency>
<groupId>net.lightbody.bmp</groupId>
<!-- note the new artifactId -->
<artifactId>browsermob-core</artifactId>
<version>2.1.2</version>
</dependency>

What is the "official" way to use Selenium 2 (Selenium WebDriver) with Maven?

I'm just trying to make the basic Selenium2Example work with Firefox 4 using Maven to get the Selenium jars :
public class Selenium2Example {
public static void main(String[] args) {
// Create a new instance of the Firefox driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
WebDriver driver = new FirefoxDriver();
// And now use this to visit Google
driver.get("http://www.google.com");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));
// Enter something to search for
element.sendKeys("Cheese!");
// Now submit the form. WebDriver will find the form for us from the element
element.submit();
// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());
//Close the browser
driver.quit();
}
}
If I go there : http://code.google.com/p/selenium/wiki/UsingWebDriver, it says I should try a dependency like this :
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium</artifactId>
<version>2.0b3</version>
</dependency>
but the latest jars can be found in no repositories, the last version which works (with all dependencies found) is "2.0a4" (2.0a5 to 2.0a7 and 2.0b1 to 2.0b3 have missing main jars or missing dependencies), and this "2.04" version doesn't have the right classes to make the example work.
If I go there : http://seleniumhq.org/docs/03_webdriver.html#chapter03-reference, it says I should use this dependency :
<dependency>
<groupId>org.seleniumhq.webdriver</groupId>
<artifactId>webdriver-firefox</artifactId>
<version>0.9.7376</version>
</dependency>
It makes the example compile, but this release hasn't been updated since october 2009, and it doesn't run with Firefox 4 (see http://repo1.maven.org/maven2/org/seleniumhq/webdriver/webdriver-firefox/)
If I go there http://seleniumhq.org/download/maven.html, it says I should try something like :
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>...</version>
</dependency>
But the 2.0b3 version doesn't work either (missing dependencies). Here is the error message :
23/05/11 22:09:07 CEST: Build errors for first-webdriver-test; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project first-webdriver-test: Unable to get dependency information for org.apache.httpcomponents:httpcore:jar:4.0.1: Failed to process POM for org.apache.httpcomponents:httpcore:jar:4.0.1: Non-resolvable parent POM org.apache.httpcomponents:httpcomponents-core:4.0.1 for org.apache.httpcomponents:httpcore:4.0.1: Failed to resolve POM for org.apache.httpcomponents:httpcomponents-core:4.0.1 due to Missing:
----------
1) org.apache.httpcomponents:httpcomponents-core:pom:4.0.1
----------
1 required artifact is missing.
for artifact:
org.apache.httpcomponents:httpcomponents-core:pom:4.0.1
from the specified remote repositories:
central (http://repo1.maven.org/maven2, releases=true, snapshots=false)
I don't know the meaning of this error, since I can find the requested pom here : http://repo1.maven.org/maven2/org/apache/httpcomponents/httpcomponents-core/4.0.1/httpcomponents-core-4.0.1.pom
So the only way I can make the example work for now, is manually downloading the 2.0b3 jars.
Does anybody succeed in making it work with Maven ?
Since RC2, you just need:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium</artifactId>
<version>2.0rc2</version>
<type>pom</type>
</dependency>
For me this is working (with Maven 2.2.1):
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium</artifactId>
<version>2.0b3</version>
<type>pom</type>
</dependency>
Notice this line: <type>pom</type>
Also, I had to add the dependency on the junit library to get it to pass some surefire exceptions, but you might not need this.
With RC3 you need:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.0rc3</version>
</dependency>
to include all the jar
For me, this works:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.29.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.29.1</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>

Do I need to install glassfish server to use it as embedded server in application?

I am trying to use glassfish as a embedded server in my ejb3.1 project.
below are my maven dependencies..
But when I run my tests it fails to deploy ejb modules.
do I need to set javaee.home or some more variable ?
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1-SNAPSHOT</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-static-shell</artifactId>
<version>3.1-SNAPSHOT</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
The exception is..
Caused by: org.omg.CORBA.DATA_CONVERSION: vmcid: SUN minor code: 214 completed: No
.
.
.
Caused by: java.lang.IllegalStateException: java.lang.RuntimeException: java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key iiop.cannot_find_keyalias
No. even you dont need glassfish-embedded-static-shell.jar.
If you want to use EJB3.1 only glassfish-embedded-all jar is enough.
If you want to access jpa data sources from ejb3 then you need a domain.xml file in classpath.
You will need to pass property "org.glassfish.ejb.embedded.glassfish.installation.root" while creating a EJB container in client code.(like EJBContainer.createEJBContainer(prop)). value of this property should be a folder name (ex. glassfish).
The folder should have domains\domain1\config\domain.xml file.
You can download and install glassfish v3 and from installation you can copy this file.