Selenium 3.0.x with HTMLUnitDriver - java

I have selenium-java 3.0.1 in my Maven project. I have read that this version does not come packaged with HTMLUnitDriver. So, I have separately included selenium-htmlunit-driver 2.52.0 in my pom (the latest version available). However, when I do this, I get the following exception on test run:
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.sslcontext
According to this link, including the selenium-java and selenium-htmlunit-driver dependencies should be sufficient. In some scenarios, the standalone server may need to be included as well, which is not the case for my project. I tried it anyway, and that didn't work either.
selenium-htmlunit-driver 2.52.0 is internally dependent on org.apache.httpcomponents 4.5.1.
selenium-java 2.47.0 uses htmlunit-driver 2.47.0 which uses org.apache.httpcomponents 4.4.1. When I use these versions, everything works correctly.
So my question is, can HTMLUnitDriver not be used with Selenium 3.0.x at all? Or is my understanding completely wrong here?

Selenium has changed artifact id. Use htmlunit-driver instead.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.23.2</version>
</dependency>
See also:
https://github.com/SeleniumHQ/htmlunit-driver

Related

Confused about TestNG version# and Selenium-JAVA version# - How to get version number for Maven POM.xml file

I've Eclipse and TestNG. I've played around with several projects using testng.xml. Now I want to run the projects using POM.xml. I've installed maven and created a new maven project. After creating a script I opened my pom.xml file and copied a sample pom.xml file that I copied from online but unfortunately I received TestNG dependency error. I assumed the error was because of incorrect TestNG version. So I went to Eclipse menu Help->About Eclipse IDE->Installation Details and got the version# of the TestNG that I'd installed.
TestNG M2E (Maven) Integration (Optional) 7.2.0.202004281604 org.testng.eclipse.maven.feature.feature.group TestNG Team
So I added the 7.2.0 to TestNG dependency to my Pom.xml but it's still showing error for TestNG dependency
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.2.0</version>
<scope>test</scope>
</dependency>
After some research I found this site https://mvnrepository.com/artifact/org.testng/testng
My question is why does eclipse show that I installed 7.2.0 version of TestNG when there is no 7.2.0 TestNG version to begin with? Anyhow version 7.3.0 finally worked. I don't understand why did version 7.3.0 work when I've 7.2.0 version installed on my machine.
My second question is how do I find out what my Selenium-Java version I've installed on my machine?
I've tried looking under Java Build Bath->Libraries tab and noticed that JRE System Library has JAVASE-13 and the Classpath is showing different version for different jar files. For example
byte-buddy-1.8.15.jar
client-comined-3.141.59-srouces.jar
commons-codec-1.13.jar
Can someone please help me how do I go about finding out the correct selenium-java version?
Shouldn't maven just download the version I add under dependency?
Thanks in advance
"TestNG M2E (Maven) Integration" is an Eclipse plugin for integrating with TestNG. You have version 7.2 of that plugin.
That's completely different from the actual TestNG library.
Shouldn't maven just download the version I add under dependency?
Yes, it will download and use whatever you tell it to (provided it exists). Whether you have another version somewhere else on your computer is irrelevant.

Recipe for using Selenium WebDriver from a Servlet running in Tomcat

I realise that my scenario is not the normal use of Selenium, but I do need to do this, I don't want an alternative architecture!
I need
(Demo Browser) -get-> Servlet-in-Tomcat using Selenium WebDriver ---> Another Web App
My problem is I'm hitting some classpath issues of the kind reported in this question - I don't understand how to apply any of the suggested solutions.
What I did:
Install Selenium using maven as described here, I have used
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
as per the article, but I'm not sure whether I should be using that combination.
Convert to Eclipse project using mvn eclipse:eclipse
In Eclipse, write some Java against the WebDriver API. This all compiles and runs perfectly.
Create a Dynamic Web Project and write a servlet. Again no issue.
Grab my Selecium-based code and move it into the servlet project, selectively merge in the entries from the selenium .classpath file - I the check the build paths in the project Properties it seems to be consistent.
Project launches but hits the class not found error, exactly as reported in the other question.
As I write this I'm beginning to realise that I've not correctly set up my Tomcat classpath - not sure how best to do that.
What would be the best recipe for getting this scenario to work?
You will have to use below dependency
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
Also for tomcat issue follow Using Selenium in a Java Dynamic Web Project

Could not find or load main class org.testng.remote.RemoteTestNG - in Eclipse

I've tried to update Selenium webdriver version and now i cant run my tests because of following exception:
Error: Could not find or load main class
org.testng.remote.RemoteTestNG
Environment on which it was working fine:
Selenium 2.53 jar
Webdriver 2.53.1
Java 7
Environment that rises an Error:
Selenium 3.5 jar
Webdriver 3.5
Java 8
I need to run it from eclipse, not commnd line
Some points to check:
Check your build path and make sure all required packages are present there.
Make sure your build path does not contain any redundant packages
Check for packages compatibility
Eventually move out from the manual packages managing and let Maven do it for you.
Always Try to use the latest version of TestNG:
From Properties>TestNG>
You can uncheck the box called "Use project TestNG jar"
Date-19-June-2019
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>

JSP support in Jetty 9.3

I'm trying to upgrade embedded Jetty to the latest version (9.3.2.v20150730 as of now) from an older release (9.3.0.M1).
I'm using JSP and current maven dependency is as follows:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>9.3.0.M1</version>
</dependency>
However I can't find a new version for this dependency in maven central.
Looks like they have not released new jetty-jsp artifacts after 9.3.0.M1 for Jetty 9.3. New versions for all other jetty-related artifacts are available.
What is the alternative I should use for JSP support with latest Jetty version?
I got the answer from jett-users mailing list. Updated dependency is:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jsp</artifactId>
<version>${jetty.version}</version>
</dependency>
Also, from jetty-announce list:
The 9.2 release has switched to using the Apache version of Jasper for
JSP and JSTL. Early releases of Jetty used these implementations,
but switched to Glassfish when it became the reference implementation.
However the Apache version is now more rigorously maintained and hence
we have switched back. Currently we are using a slightly modified
version of 8.0.3, however our modifications have been contributed
back to apache and have been accepted for their 8.0.9 release, so we
will soon switch to using a standard jar from Apache.
Apparently they have switched back to standard jar from Apache.

What Maven Artefact holds PowerMock.mockStaticPartial?

A few Powermock/Mockito articles mentioned use of a PowerMock.mockStaticPartial method - the only problem is I can't find it anywhere!
Does anyone know which artifact and version this exists/existed in?
It is definitely in v1.4.11 of powermock-api-easymock see powermock-api-easymock-1.4.11.jar for Maven/Ivy details and a view of the .jar itself.
The Maven dependency is:
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>1.4.11</version>
</dependency>
If you are using Mockito as well, you should be aware of the version compatibility between Mockito and PowerMock, see http://code.google.com/p/powermock/wiki/MockitoUsage13 for which versions work together.
I think this method is since API 1.2. Check the PowerMock wiki Maven setup, there are the dependencies for each of it's parts. The dependencies are version 1.4.12 so they should include mockStaticPartial.

Categories