2017-08-11 6 views
0

私はIDEとしてIntellijを使用し、パッケージマネージャとしてmavenを使用してjavaを使用してセレンテストを学習しています。次のようにIntellij IDEAのシンボルエラーを解決することができません

私のpom.xmlがある:

<?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>depositTest</groupId> 
    <artifactId>deposittest</artifactId> 
    <version>1.0-SNAPSHOT</version> 

    <dependencies> 
     <!-- https://mvnrepository.com/artifact/junit/junit --> 
     <!-- https://mvnrepository.com/artifact/junit/junit --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.12</version> 
      <scope>test</scope> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/org.testng/testng --> 
     <dependency> 
      <groupId>org.testng</groupId> 
      <artifactId>testng</artifactId> 
      <version>6.9.10</version> 
      <scope>test</scope> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-java</artifactId> 
      <version>2.53.0</version> 
     </dependency> 


    </dependencies> 
</project> 

次のように私のimport文は次のとおりです。

import org.testng.annotations.BeforeTest; 
import org.testng.annotations.Test; 
import org.testng.annotations.AfterTest; 
import java.util.concurrent.TimeUnit; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.By; 
import static org.junit.Assert.*; 
import static org.testng.AssertJUnit.assertEquals; 
import org.openqa.selenium.WebDriver; 

しかし、私はIDEでTestNGのとJUnitライブラリをcan not resolve symbol errorsを取得します。私は間違って何をしていますか?

+0

Mavenサイドバーで[インポート]オプションを試しましたか? –

+0

自動的にインポートし、何度も再インポートするように設定します。 –

+0

http://stackoverflow.com/a/42427510/104891を参照してください。それがIntelliJ IDEAの外部のコマンドラインから動作することを確認してください。 – CrazyCoder

答えて

0

JUnitTestNGの両方について、<dependency>セクションに<scope>test</scope>を指定しました。

したがって、これらのライブラリはsrc/test/java内でのみ使用されます。

src/main/javaでこれらのクラスを参照しているかどうか確認してください。 IntelliJのはあなたの問題を解決するにはsrc/main/java

でのJUnitやTestNGのクラスを解決しません

、TestNGのとJUnitの両方のためにあなたの<dependency>から<scope>タグを削除し、再度お試しください。

関連する問題