I tried running the following code to start running Selenium WebDriver on Java, using the following code
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();
}
}
I get the exception java.lang.RuntimeException: java.lang.IllegalAccessException: Class org.openqa.selenium.support.PageFactory can not access a member of class moronicpackage.GoogleSearchPage with modifiers ""
Any ideas?