我正在尝试使用HtmlUnitDriver登录网站,并且不断收到java.lang.error。
我添加了多个jar来修复我的com.gargoylesoftware.htmlunit.browserversion错误,该错误已解决但导致了另一个问题。
import org.jsoup.Connection;
import org.jsoup.Connection.Response;
import org.jsoup.Connection.Method;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import java.io.IOException;
import java.net.CookieHandler;
import java.net.CookieManager;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.HasInputDevices;
public class selenium
public static void main ( String[] args ) throws IOException {
HtmlUnitDriver driver = new HtmlUnitDriver(true); // line that shows a error
String baseUrl = "website";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get(baseUrl);
driver.findElement(By.name("username")).clear();
driver.findElement(By.name("username")).sendKeys("username");
driver.findElement(By.name("password")).clear();
driver.findElement(By.name("password")).sendKeys("password");
driver.findElement(By.cssSelector("input[type='submit']")).click();
线程“主”中的异常java.lang.Error:未解决的编译问题: HtmlUnitDriver无法解析为一种类型 HtmlUnitDriver无法解析为一种类型 语法错误,插入“}”以完成ClassBody