user3170595
user3170595

Reputation: 109

JUnit and WebDriver by IntelliJ IDEA

Im working in IntelliJ and need to add dependency's to Selenum WebDriver and Junit. I already added the jars (as mentioned in all possible tutorial) to my Project lib. I can also see them in the project view - Selenium-java-2.39.0.jar, Selenium-java-2.39.0.srcs.jar, Selenium-server-standalone-2.39.0.jar AND junit-4.11.jar Nevertheless, my project can not recognized this items (for example import org.openqa.selenium.; import static org.junit.Assert.; Any ideas?

Upvotes: 0

Views: 2424

Answers (2)

ngandriau
ngandriau

Reputation: 350

I agree, you should invest in a dependency management solution, but if you are not forced to use maven, try gradle.
It is way lighter and flexible... In that case, my dependencies are resume to 1 line:

compile "org.gebish:geb-spock:0.9.2", "org.seleniumhq.selenium:selenium-firefox-driver:2.39.0", "org.seleniumhq.selenium:selenium-support:2.39.0"

I agree, I could add a second line with a property for the selenium version.

Gradle is really well supported by intellij Idea.

enjoy

Upvotes: 0

ddavison
ddavison

Reputation: 29032

I would recommend investing some time learning about some dependency management solutions. Here are my top two selections:

  1. Maven
  2. Ivy

If using maven, you'd have a pom.xml in your project and you'd have something like:

<dependencies>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-chrome-driver</artifactId>
      <version>${selenium_version}</version>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-htmlunit-driver</artifactId>
      <version>${selenium_version}</version>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-firefox-driver</artifactId>
      <version>${selenium_version}</version>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-safari-driver</artifactId>
      <version>${selenium_version}</version>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-ie-driver</artifactId>
      <version>${selenium_version}</version>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-support</artifactId>
      <version>${selenium_version}</version>
    </dependency>
    ...
  </dependencies>

Ivy is very similar, but i won't get into it. If you need a project to get you started, you can check out this project (download here) which is used by Major League Gaming for their selenium framework

Upvotes: 2

Related Questions