Selenium 2 (WebDriver) + Java + Maven + Eclipse Hello World Program issue

eclipse, java, maven, selenium-webdriver

Solution

Cannot reproduce.

Here's how I did it (Eclipse 4.3 Kepler, Oracle JDK 7u25):

I made a new `Hello World` Java project (right click in the Package Explorer -> `New` -> `Java project`):

I named it `Hello World` and clicked Finish. I created a new package in the `src` folder named `hello` and a new class `HelloWorld` in it:

I implemented the `HelloWorld` class and ran it (F11):

I converted the project to a Maven Project (right click on the project -> `Configure` -> `Convert to Maven Project`), clicked Finish

I fixed the errors Maven was throwing at me.

It said "Project build error: 'artifactId' with value 'Hello World' does not match a valid id pattern.", so I figured `Hello World` might be invalid because of the space. I was right. Removing the space from `Artifact Id` and `Group Id` fixed the build.

Before:

After (don't forget to save the file via Ctrl+s):

Right now, everything worked as intended. The `HelloWorld` class, when ran, still output the same thing as before. The project now had a slightly different folder structure (new `bin` and `target` folders, new `pom.xml` file):

I added Selenium dependancy. Open `pom.xml`, click the `Dependencies` tab, click Add..., find `Selenium-java`, specify version `2.33.0`.

After I clicked OK and saved the POM file, I had to wait for Maven to download all the Selenium goodies and dependencies, that took a while (observe the Progress toolbar in Eclipse doing something).

The only thing that changed was that the project structure had a new `Maven Dependencies` item containing Selenium and all of its depenedencies.

I was ready to roll with Selenium:

When run, this opens Firefox, goes to Google and finishes.

Problem

Java "Hello World" project convert to Maven Project and it stopped working with error "Error: Could not find or load main class...." Hi All, I did lot of search in google but couldn't find any Hello World program for `Selenium 2 ( WebDriver )+ Java + Maven + Eclipse` setup instructions I'm having below setup - Eclipse with Maven plugin - Created a Java project "Hello World" and it worked fine when ran as "Java Application" - Then converted this to Marven Project. - Tried to run whole project but it didn't run - Tried to run Hello World file and it's consistently failed with error "Error: Could not find or load main class...." Questions: - How to setup and run basis selenium 2 program with maven inside Eclipse - Why java stopped working after converting to Maven project. Thanks in advance. Regards, Vikram

Original source