2013-10-25 3 views
1

저는 scala에 익숙하지 않지만 Selenium과 함께 ScalaTest를 사용하고자합니다. 예제를 직접 복사하여 http://www.scalatest.org/user_guide/using_selenium에서 붙여 넣었습니다. 암시 적 변환 발견 -scalatest 셀레늄 예제 컴파일 오류

이 줄 에서 여러 마커 :하지만

"The blog app home page" should "have the correct title" in { 
    go to (host + "index.html") 
    pageTitle should be ("Awesome Blog") 
} 

오류 키워드 '에서'직전이 '{'라고하는 것을 아래의 문에 오류가있어 : "블로그 응용 프로그램 홈 페이지"에 올바른 제목이 있어야 함 => convertToInAndIgnoreMethods ("블로그 응용 프로그램 홈 페이지"에 "올바른 제목이 있어야 함") - 대안을 사용한 메소드 값 오버로드 : (testFun : BlogSpec.this .FixtureParam => Any) Unit (testFun :() => Any) 단위는 (단위)에 적용 할 수 없습니다.- 대체 값으로 오버로드 된 메소드 값 : (testFun : BlogSpec.this.FixtureParam => Any) Unit (testFun :() => Any) 단위를 (Unit) 에 적용 할 수 없음 - 암시 적 변환을 발견 함 : "블로그 앱 홈 페이지 "=> convertToStringShouldWrapper (는" 블로그 응용 프로그램 홈 페이지 ")

내가 받는다는 통해 모든 권리 버전을 따기있어 생각이 주위에 얻을 수

<dependency> 
    <groupId>org.scala-lang</groupId> 
    <artifactId>scala-library</artifactId> 
    <version>2.10.2</version> 
</dependency> 
<dependency> 
    <groupId>junit</groupId> 
    <artifactId>junit</artifactId> 
    <version>4.11</version> 
    <scope>test</scope> 
</dependency> 
<dependency> 
    <groupId>org.specs2</groupId> 
    <artifactId>specs2_2.10</artifactId> 
    <version>1.13</version> 
    <scope>test</scope> 
</dependency> 
<dependency> 
    <groupId>org.scalatest</groupId> 
    <artifactId>scalatest_2.10</artifactId> 
    <version>2.0.M6-SNAP8</version> 
    <scope>test</scope> 
</dependency> 
<dependency> 
    <groupId>org.seleniumhq.selenium</groupId> 
    <artifactId>selenium-java</artifactId> 
    <version>2.37.0</version> 
</dependency> 
    ... 
    <plugin> 
    <!-- see http://davidb.github.com/scala-maven-plugin --> 
    <groupId>net.alchim31.maven</groupId> 
    <artifactId>scala-maven-plugin</artifactId> 
    <version>3.1.3</version> 
    <executions> 
     <execution> 
     <goals> 
      <goal>compile</goal> 
      <goal>testCompile</goal> 
     </goals> 
     <configuration> 
      <args> 
      <arg>-make:transitive</arg> 
      <arg>-dependencyfile</arg> 
      <arg>${project.build.directory}/.scala_dependencies</arg> 
      </args> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 

시도를 많이하지만, 실패한. 어떤 도움이라도 대단히 감사 할 것입니다. 또한 https://bitbucket.org/olimination/hello-scalajava.git을 시도했지만 maven 오류로 인해 실행되지 않았습니다.

답변

1

이 질문은 꽤 오래된 질문 인 것 같습니다. 이미 다 알아 들었지만 샘플은 저를 위해 컴파일됩니다.

import 문에 문제가 있다고 생각합니다. 예를 들어 IntelliJ Idea는 잘못된 것을 제안하는 것으로 보이며 import org.scalatest._을 사용할 때 모두 괜찮은 것처럼 보입니다. 그렇지 않으면 정확하게 컴파일 오류가 발생합니다.

이 전체 소스입니다 :

import org.openqa.selenium.WebDriver 
import org.openqa.selenium.htmlunit.HtmlUnitDriver 
import org.scalatest.selenium.WebBrowser 

import org.scalatest._ 

class BlogSpec extends FlatSpec with ShouldMatchers with WebBrowser { 

    implicit val webDriver : WebDriver = new HtmlUnitDriver 

    val host = "http://localhost:9000/" 

    "The blog app home page" should "have the correct title" in { 
     go to (host + "index.html") 
     pageTitle should be("Awesome Blog") 
    } 
} 

나는이 내 pom.xml이다 (당신이 할 수있는 경우 여기 어쨌든 2.10를 유지하고있어,도 및 스칼라) 프레임 워크와 플러그인의 최신 버전을 사용하는 것이 좋습니다 :

<?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>test</groupId> 
    <artifactId>scalatest-selenium</artifactId> 
    <version>1.0-SNAPSHOT</version> 

    <dependencies> 
     <dependency> 
      <groupId>org.scala-lang</groupId> 
      <artifactId>scala-library</artifactId> 
      <version>2.10.2</version> 
     </dependency> 
     <dependency> 
      <groupId>org.scalatest</groupId> 
      <artifactId>scalatest_2.10</artifactId> 
      <version>2.2.1</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-java</artifactId> 
      <version>2.42.2</version> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <!-- disable surefire --> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.7</version> 
       <configuration> 
        <skipTests>true</skipTests> 
       </configuration> 
      </plugin> 
      <!-- enable scalatest --> 
      <plugin> 
       <groupId>org.scalatest</groupId> 
       <artifactId>scalatest-maven-plugin</artifactId> 
       <version>1.0</version> 
       <configuration> 
        <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory> 
        <junitxml>.</junitxml> 
        <filereports>WDF TestSuite.txt</filereports> 
       </configuration> 
       <executions> 
        <execution> 
         <id>test</id> 
         <goals> 
          <goal>test</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <!-- see http://davidb.github.com/scala-maven-plugin --> 
       <groupId>net.alchim31.maven</groupId> 
       <artifactId>scala-maven-plugin</artifactId> 
       <version>3.1.7-SNAPSHOT</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>compile</goal> 
          <goal>testCompile</goal> 
         </goals> 
         <configuration> 
          <args> 
           <arg>-make:transitive</arg> 
           <arg>-dependencyfile</arg> 
           <arg>${project.build.directory}/.scala_dependencies</arg> 
          </args> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 
+0

답장을 보내 주셔서 감사합니다. 매우 감사! – RayCh