简体   繁体   中英

Error When Compiling Maven Selenium Project - Compilation Error packages not found

I tried to run maven project of Selenium testing (maven -install)

Below is the pom

<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>deprecated</groupId>
<artifactId>deprecated</artifactId>
<version>0.0.1-SNAPSHOT</version>

<dependencies>
     <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.46.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>2.46.0</version>
    </dependency>
    <dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>6.9.4</version>
  <scope>test</scope>
</dependency>
</dependencies>

<build>

 <sourceDirectory>src</sourceDirectory>
    <plugins>
    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.14.1</version>
            <configuration>
             <archive>
            <manifest>
              <addClasspath>true</addClasspath>
            </manifest>
          </archive>
            <forkMode>never</forkMode>
                <suiteXmlFiles>
                    <suiteXmlFile>testsuite/TestSuiteBukalapak.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>

</project>

Compilation error complaining package org.openqa.selenium does not exist, package org.testng does not exist, package org.testng.annotations does not exist and others as if the maven build is missing something.

[INFO] Compiling 43 source files to D:\deprecated\selenium_testng\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /D:/deprecated/selenium_testng/src/deprecated/Tambah_Alamat.java:[3,27] package org.openqa.selenium does not exist
[ERROR] /D:/deprecated/selenium_testng/src/deprecated/Tambah_Alamat.java:[4,27] package org.openqa.selenium does not exist
[ERROR] /D:/deprecated/selenium_testng/src/deprecated/Tambah_Alamat.java:[5,35] package org.openqa.selenium.support does not exist
[ERROR] /D:/deprecated/selenium_testng/src/deprecated/Tambah_Alamat.java:[6,18] package org.testng does not exist
[ERROR] /D:/deprecated/selenium_testng/src/deprecated/Tambah_Alamat.java:[7,30] package org.testng.annotations does not exist
[ERROR] /D:/deprecated/selenium_testng/src/deprecated/core/Settings.java:[5,27] package org.openqa.selenium does not exist
[ERROR] /D:/deprecated/selenium_testng/src/deprecated/core/Settings.java:[6,34] package org.openqa.selenium.chrome does not exist
[ERROR] /D:/deprecated/selenium_testng/src/deprecated/core/Settings.java:[7,34] package org.openqa.selenium.chrome does not exist
[ERROR] /D:/deprecated/selenium_testng/src/deprecated/core/Settings.java:[8,34] package org.openqa.selenium.chrome does not exist
[ERROR] /D:/deprecated/selenium_testng/src/deprecated/core/Settings.java:[9,35] package org.openqa.selenium.firefox does not exist
[ERROR] /D:/deprecated/selenium_testng/src/deprecated/core/Settings.java:[10,35] package org.openqa.selenium.firefox does not exist
[ERROR] /D:/deprecated/selenium_testng/src/deprecated/core/Settings.java:[11,42] package org.openqa.selenium.support.events does not exist
[ERROR] /D:/deprecated/selenium_testng/src/deprecated/core/Settings.java:[12,18] package org.testng does not exist

Can you please help give me a clue, any specific dependency I need to insert on the pom ? Thanks

try adding

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>${selenium.version}</version>
    </dependency>

You can add below depdency and give it a try:

<dependency>
    <groupId>org.openqa.selenium.server</groupId>
    <artifactId>selenium-server-coreless</artifactId>
    <version>1.0-20081010.060147</version>
</dependency>

More detail here

I met the issue today just the same as you. Here is the way I fix it:

  1. I downloaded "geckodriver V0.10.0" here: https://github.com/mozilla/geckodriver/releases , I use mac, so the file I choose is: geckodriver-v0.10.0-macos.tar.gz

  2. I also update the selenium-server version to 3.0.0-beta2 from here: http://www.seleniumhq.org/download/ => [Download version 3.0.0-beta2]

  3. Last, I set the required property for using "geckodriver" in code before new FirefoxDriver:

    System.setProperty("webdriver.gecko.driver","/xxx/yyy/geckodriver");

Then it worked, hope it will be helpful for you.

To the end I found the imported package has changed from "org.openqa.selenium.server.SeleniumServer; " to "org.openqa.selenium.remote.server.SeleniumServer"

*For other reference: http://learn-automation.com/use-firefox-selenium-using-geckodriver-selenium-3/

Trying to Replace Selenium Dependancy

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.59</version>
</dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM