I am trying to follow along with the examples found at https://code.google.com/p/selenium/wiki/GettingStarted , but I ran into a package org.openqa.selenium.exampleerror. The rest of the code looks fine, except public class Exampleit also has a red dot saying that it needs to be declared, but I decided that this is because the above package has problems.
When I run the code, this is the output:
Error: Could not find or load main class test.Test
/Users/me/Library/Caches/NetBeans/8.1/executor-snippets/run.xml:53: Java returned: 1
BUILD FAILED (total time: 3 seconds)
I know that there is a similar thread that can be found here: I can’t run the Java example for Selenium / WebDriver , but this is the first time I use both Java and Selenium, it’s still hard for me to deal with this problem. If you do not want to follow the link to an example, here is my code:
package org.openqa.selenium.example;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class Example {
public static void main(String[] args) {
WebDriver driver = new HtmlUnitDriver();
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Cheese!");
element.submit();
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
}
}
EDIT:

