0

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?

djna
  • 54,992
  • 14
  • 74
  • 117
  • https://www.seleniumhq.org/download/maven.jsp This page may help. From page "Note: Be aware, that the selenium-server artifact has a dependency to the servlet-api-3.1.0 artifact, which you should exclude, if your project will be run inside a web application container" – Rahul L Aug 15 '19 at 06:26

1 Answers1

1

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

Rahul L
  • 4,249
  • 15
  • 18