0

I am a programmer new to Java world. I am using Intellij-idea, Maven, & Selenium.

I followed instructions exactly to generate Selenium Project. The link is: http://www.seleniumhq.org/docs/03_webdriver.jsp

The directions ask you to

  • create project folder
  • drop pom.xml they gave you into Project folder
  • edit group & artifact tags of the Pom.xml
  • Run “mvn clean install” command

So I am enclosing the pom.xml I used, and I followed directions above using “FWSDriverProject” as my folder (for pom.xml file, see bottom of this message).

Since I don’t have an old version of Intellij, and the directions on the Selenium site are old, I couldn’t follow them exactly, but I did notice that a jar file was created for me in target subfolder of the project, and I am familiar on how to use jar files so I thought it worth a shot.

I created folder called C:\Java\FWS_SeleniumJarConsumer & then created simple command-line app within that folder.

I added libs folder, C:\Java\FWS_SeleniumJarConsumer\libs.

Then I dropped the JAR file created for me, into this folder.

Then, within Intellij, I opened my FWS_SeleniumJarConsumer project, and I right-clicked on the jar file and selected “Add to Library”.

I was greeted with “IDEA cannot determine what kind of files the chosen items contain. Choose the appropriate categories from the list.”

It allows you to select multiple. Since I wasn't sure what to select, I chose all of them.

I didn't get any errors.

But when trying to use the imports provided in the sample code, I get error.

import org.openqa.selenium.By;

The error say: “Cannot resolve symbol openqa”

Any ideas on how to get basic Selenium project up and running using IntelliJ & Java?

I am using latest Maven and IntelliJ-idea. Tutorial on link is old.

        <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
            <modelVersion>4.0.0</modelVersion>
            <groupId>HCFCD</groupId>
            <artifactId>FWSDriver</artifactId>
            <version>1.0</version>
            <dependencies>
                <dependency>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-java</artifactId>
                    <version>2.53.0</version>
                </dependency>
                <dependency>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>htmlunit-driver</artifactId>
                    <version>2.21</version>
                </dependency>
            </dependencies>
    </project>
Sir Fartsalot
  • 125
  • 2
  • 12

1 Answers1

0

I did a similar project and I followed this tutorial to be able to create maven build and execute Selenium test in Java with IntelliJ. This should solve your problem.

Look at this video: https://www.youtube.com/watch?v=rQG_GBTFWQ4

Git repository: https://github.com/Krotov/FirstWebDriverTest

Mathieu

  • Had trouble with this. Maven doesn't pop up on the list when importing project from Model. Eclipse Shows Gradle Shows. I don't see Maven on the list. – Sir Fartsalot Jun 29 '16 at 20:28
  • I got passed MAVEN not showing up on list through CONFIGURE PLUGINS, enable MAVEN.... – Sir Fartsalot Jun 30 '16 at 12:51
  • Try to: Right click the project->Configure->Convert to Maven Project if this does not work, I will do a test to check if I have the same problem – Mathieu Vézina Jun 30 '16 at 13:39
  • Look at this tutoriel, this is a great site to create a new maven project : http://toolsqa.com/java/maven/create-new-maven-project/ – Mathieu Vézina Jun 30 '16 at 13:43
  • Mathieu, I looked at your links in the main answer above. I get: Failed to connect to binary Firefox binary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7055; process output follows: (..) Tests run 4: Failures: 1, Errors: 0, Skipped: 3. ...... Please refer to C:\SeleniumTests\FirstWebDriverTest\target\sunfire=reports for the individual tests results... – Sir Fartsalot Jul 05 '16 at 20:20
  • Someone has already found a solution to this error : http://stackoverflow.com/questions/13514338/failed-to-connect-to-binary-firefoxbinary-with-selenium-in-maven – Mathieu Vézina Jul 05 '16 at 20:29
  • I will keep playing with it... I will accept answer after I figure it out.... Thanks so much for helping! – Sir Fartsalot Jul 06 '16 at 13:17
  • Mahtieu, I did go through the second tutorial you mentioned. toolsqa.com/java/maven/create-new-maven-project I am using Intellij. I am able to issue command "mvn clean test" It ran successfully. I don't know what it did. Where does execution begin? What is it doing? – Sir Fartsalot Jul 06 '16 at 15:53
  • When you do a mvn clean test only your unmarked unit tests will run. After that, you can do a mvn clean install. The integration tests are run during the integration-test phase. Maybe this will help you : http://stackoverflow.com/questions/1399240/how-do-i-get-my-maven-integration-tests-to-run – Mathieu Vézina Jul 06 '16 at 17:13
  • ok, I think we are going on tangent and this is bigger learning curve than I thought. I will accept your answer and if I run into more issues, will just ask another question. Thanks for all your help. – Sir Fartsalot Jul 06 '16 at 18:38