Selenium 2 (WebDriver) + Java + Maven + Eclipse Hello World Program issue
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 thesrc
folder namedhello
and a new classHelloWorld
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 FinishI 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 fromArtifact Id
andGroup 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 (newbin
andtarget
folders, newpom.xml
file):I added Selenium dependancy. Open
pom.xml
, click theDependencies
tab, click Add..., findSelenium-java
, specify version2.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.
vikramvi
Updated on July 05, 2022Comments
-
vikramvi almost 2 years
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 instructionsI'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