- Learning Selenium Testing Tools(Third Edition)
- Raghavendra Prasad MG
- 419字
- 2025-02-22 16:26:18
Merging of two projects
Both Simon Stewart and Jason Huggins thought that it would be a really good idea to merge the two projects together. This was then called Selenium 2.
The Selenium core developers have been working really hard to simplify the code base and remove as much duplication as possible. We have created what is known as Selenium Atoms, which is then shared between the two projects.
Now that we know the basics of how it all hangs together, let's set up a project that we can use for the rest of the chapter. By performing the steps in the link given below, we would be able to set up our Java environment:
- Install JDK 1.6 or higher from the Oracle website: http://www.oracle.com/technetwork/java/javase/downloads/index.html.
- To set up Java environment, refer to http://www.tutorialspoint.com/java/java_environment_setup.htm.
Setting up the IntelliJ IDEA project
We will be setting up IntelliJ IDEA project using JUnit as the testing framework to drive our tests. Let's get started with the following steps:
- Open IDEA and create a new project:
- Create a directory at the root of the project called
test
using New | Directory: - Click on File | Project structure.
- Click on Modules on the left-hand side of the dialog box that has loaded.
- Click on the
test
folder that you created in the folder tree on the right-hand side of the dialog box: - Click on the Test Sources button and the
test
folder should turn green. It will look like the following screenshot: - Click on File | Project structure.
- Then, click on Global libraries.
- Click on the + button to add a New Global library. Then, select Java.
- Click on Attach Classes and add
selenium.jar
andcommon.jar
. This should be in the same place as yourSelenium-Server.jar
. When added, it should look like the following screenshot: - Do the same for JUnit now. You can create a New Global library for it or add it to the Selenium Global Library.
- Click on the Modules link on the left-hand side again.
- Click on the Dependencies tab.
- Click on Add and then click on Global Libraries. Add the Selenium and JUnit libraries.
- Click on Apply.
- We are now ready to run Selenium Server. We do this by running
java–jar selenium-server.jar
from Command Prompt or from a terminal, depending on your operating system.
Your project is ready to have tests added to it. Each of the files that we create from now on will be placed in the test directory and can be run when we need to.