-2

私はHtmlUnitDriverでスクリプトを書いていますが、何かエラーがあります。エラー "java.lang.NoClassDefFoundError"が表示されます。私を助けてください。以下のコードとエラーを確認してください。ここで私はHtmlUnitDriverにスクリプトを書いていますが、何かエラーがあります

はコードです:ここでは

package com.pom.sampletests; 

     import org.openqa.selenium.By;  
     import org.openqa.selenium.WebDriver; 
     import org.openqa.selenium.WebElement; 
     import org.openqa.selenium.htmlunit.HtmlUnitDriver;  
     public class HtmlUnitYest {    
      public static void main(String[] args) throws Exception { 
       // Creating a new instance of the HTML unit driver 

       WebDriver driver = new HtmlUnitDriver(); 

       Thread.sleep(2000L); 
       // Navigate to Google  
       driver.get("http://www.google.com");     

       // Locate the searchbox using its name  
       WebElement element = driver.findElement(By.name("q")); 

       // Enter a search query   
       element.sendKeys("Guru99");  

       // Submit the query. Webdriver searches for the form using the text input element automatically  
       // No need to locate/find the submit button   
       element.submit();   

       // This code will print the page title  
       System.out.println("Page title is: " +   driver.getTitle());   

       driver.quit();   
      }  
     } 

エラーです:

Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException 
    at com.pom.sampletests.HtmlUnitYest.main(HtmlUnitYest.java:11) 
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.SessionNotFoundException 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 

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>TestNGPro</groupId> 
    <artifactId>TestNGPro</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <name>CBA Automation</name> 



      <build> 
     <finalName>TestNGPro</finalName> 
     <!-- <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> 
      <source>${java.version}</source> <target>${java.version}</target> </configuration> 
      </plugin> --> 
     </build> 
     <dependencies> 
     <dependency> 

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

     <dependency> 
      <groupId>org.testng</groupId> 
      <artifactId>testng</artifactId> 
      <version>6.10</version> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-htmlunit-driver --> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-htmlunit-driver</artifactId> 
      <version>2.52.0</version> 
     </dependency> 


     </dependencies> 

     <properties> 
     <java.version>1.6</java.version> 
     <selenium.version>3.1.0</selenium.version> 
     </properties> 
    </project> 

任意の提案がかもしれ役に立ちます。

+0

あなたのポンポンを更新する質問&達人であなたのPOMを投稿し、何が起こるかを見ることができます。.. –

+0

エラーまだましな問題では変更はありません。 –

+0

あなたの質問にPOMを投稿してください。 –

答えて

0

セレンのバージョンを2.53.0に劣化させて問題を解決しました。

+0

に追加してください。 –

+0

セレン2.53.0は正常に動作しています。 –

0

artifact-idhtmlunit-driverに変更されました。

最新バージョンは以下のようになります。

<dependency> 
    <groupId>org.seleniumhq.selenium</groupId> 
    <artifactId>htmlunit-driver</artifactId> 
    <version>2.24</version> 
</dependency> 
関連する問題