VapiSoft
asked on
Getting Stated with Java
Hi,
I am getting-stated with Java because I want to use Selenium 2 in Java.
I have an experience with Elipse IDE for PHP and for JavaScript.
I oped a new Java Project.
and the src folder I added anew Java File and copied the GettingStated Selenium file to is (as my first Java application).
Now I want to run it.
I added the file as the main class to the "Run Configuration" and Run it (Apply).
I received and error: Could not find the main class: src/GettingStated.js. Program will exit.
I am getting-stated with Java because I want to use Selenium 2 in Java.
I have an experience with Elipse IDE for PHP and for JavaScript.
I oped a new Java Project.
and the src folder I added anew Java File and copied the GettingStated Selenium file to is (as my first Java application).
Now I want to run it.
I added the file as the main class to the "Run Configuration" and Run it (Apply).
I received and error: Could not find the main class: src/GettingStated.js. Program will exit.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am sorry, but after I followed the examples, I still cannot compile/run the Selenuim 'Getting Started' that I downloaded.
It comes with two jar files:
selenium-java-2.0b3.jar
selenium-java-2.0b3-srcs.j ar
and a lib folder with many jar files.
I imported the jar files (from another folder to my folder)
But when I tried to add it to my space, I get a lot of X (almost every line) - see the attached picture
It comes with two jar files:
selenium-java-2.0b3.jar
selenium-java-2.0b3-srcs.j
and a lib folder with many jar files.
I imported the jar files (from another folder to my folder)
But when I tried to add it to my space, I get a lot of X (almost every line) - see the attached picture
package org.openqa.selenium.example;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class MyFirstClass {
public static void main(String[] args) {
// Create a new instance of the Firefox driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
WebDriver driver = new FirefoxDriver();
// And now use this to visit Google
driver.get("http://www.google.com");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));
// Enter something to search for
element.sendKeys("Cheese!");
// Now submit the form. WebDriver will find the form for us from the element
element.submit();
// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());
//Close the browser
driver.quit();
}
}
ScreenShot-4863.jpg
You need to add all the jars to your classpath. Classpath is kind of like the Windows PATH variable to Java -- it defines the locations and jar files where other classes needed by your class can be found.
I'm working from memory at the moment but I think you need to right click on the project, select Properties, find Build Path in the project properties tree (maybe under Java?) and then there should be a tab where you can add the jars to your classpath.
I'm working from memory at the moment but I think you need to right click on the project, select Properties, find Build Path in the project properties tree (maybe under Java?) and then there should be a tab where you can add the jars to your classpath.
Looked up the Eclipse help; it's on the Libraries tab:
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/ref-properties-build-path.htm
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/ref-properties-build-path.htm
ASKER
The second link is very helpful.