intellij에서 HtmlUnitDriver를 사용하여 테스트를 작성했습니다. 코드는 다음과 같습니다 내가 Gradle을 사용하는 경우빌드가 녹색이지만 java.lang.NoSuchMethodError가 나타나는 이유는 무엇입니까?
이import junit.framework.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class HtmlUnitDemo {
WebDriver driver;
public static void main(String args[]){
HtmlUnitDemo obj = new HtmlUnitDemo();
obj.setup();
obj.openURL();
}
public void openURL() {
driver.get("https://mail.google.com");
driver.findElement(By.id("username")).sendKeys("xyz");
driver.findElement(By.id("password")).sendKeys("pqr");
driver.findElement(By.className("btn-submit")).click();
Assert.assertEquals(driver.getTitle(), "CAS – Central Authentication Service");
}
public void setup(){
driver = new HtmlUnitDriver();
}
}
이 코드 빌드. 내가 IDE에서 실행할 때, 그것은 나에게 전체 스택 추적하는
*java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.<init>(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)
을 제공합니다
at com.gargoylesoftware.htmlunit.HttpWebConnection.createHttpClient(HttpWebConnection.java:504)
at com.gargoylesoftware.htmlunit.HttpWebConnection.getHttpClient(HttpWebConnection.java:470)
at com.gargoylesoftware.htmlunit.HttpWebConnection.setUseInsecureSSL(HttpWebConnection.java:659)
at com.gargoylesoftware.htmlunit.WebClient.setUseInsecureSSL(WebClient.java:1085)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.createWebClient(HtmlUnitDriver.java:263)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.<init>(HtmlUnitDriver.java:129)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.<init>(HtmlUnitDriver.java:172)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.<init>(HtmlUnitDriver.java:168)
at smoke.com.thoughtworks.twu.HtmlUnitDemo.setup(HtmlUnitDemo.java:30)
at smoke.com.thoughtworks.twu.HtmlUnitDemo.main(HtmlUnitDemo.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
는이 오류를 봤 그것은 뭔가 클래스 경로에 관련된 말했다. 그러나 정확히 무엇이 이루어질 지 확신하지 못합니다. 나는이 분야에 아주 새로운 사람이다. 그래서 어떤 도움을 주시면 감사하겠습니다. 미리 감사드립니다.
이는 컴파일 할 때 동일한 버전의 코드로 실행하지 않는다는 의미입니다. –
어떤 IDE를 사용하고 있습니까? – sunleo
스택 추적이 필요하지만 종속성에있는 jar 파일 중 하나가 잘못된 버전 인 것 같습니다. – Thilo