我尝试使用以下代码运行以下代码以开始在 Java 上运行 Selenium WebDriver
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.*;
public class Runner
{
public static void main(String[] args)
{
WebDriver driver;
driver = new InternetExplorerDriver();
driver.get("http://www.google.co.in");
try
{/// Exception thrown on initElements
GoogleSearchPage page1 = PageFactory.initElements(driver, GoogleSearchPage.class);
page1.SearchFor("hu ha 123");
}
catch(Exception excp)
{
System.out.println(excp.toString());
}
driver.quit();
}
}
class GoogleSearchPage
{
@FindBy(how = How.NAME, using = "q")
public WebElement searchbox;
public void SearchFor(String Text)
{
searchbox.sendKeys(Text);
searchbox.submit();
}
}
我得到异常 java.lang.RuntimeException: java.lang.IllegalAccessException: Class org.openqa.selenium.support.PageFactory can't access a member of class moronicpackage.GoogleSearchPage with modifiers ""
有任何想法吗?