How to Create a Selenium Maven Project with Eclipse to Open Chrome Browser?
Eclipse IDE: We consider using the Eclipse IDE to work with the Selenium Maven project because Eclipse is open-source software and runs across different operating systems, Eclipse is an integrated development environment (IDE) for developing applications in Java and other languages such as C, C++, Python, etc.
We will be discussing how to create a Maven project with Selenium to open the chrome browser, let’s consider a test case in which we will try to automate the following scenarios in the Google Chrome browser.
- Launch Chrome browser.
- Maximize the browser.
- Open URL: https://www.geeksforgeeks.org/
- Java: To work with selenium Java is required, so download and install the Java JDK in your system, one must be aware of how to Download and Install Java for the 64-bit machine?
- Eclipse IDE: Install the Eclipse IDE by referring to this article Eclipse IDE for Java Developers
- Chrome Driver: Download the Google Chrome browser.
Step By Step Implementation:
Step 1: Create a New Maven Project
1.1: From the File menu, choose New, and then choose Project.
1.2: In the New Project window, choose Maven Project and click next
1.3: Select the archetype to “org.apache.axis2.archetype” quickstart by entering “apache” in Filter box and click next.
1.4: Enter the Group Id and Artifact Id and click on Finish.
Step 2: Adding Dependency into the “pom.xml” file:
2.1: Go to Maven repository https://mvnrepository.com/
2.2: Search for selenium in the repository and select the Selenium java
2.3: Select the latest version and copy the dependency
2.4: Paste the dependency into “pom.xml” under the dependencies file and save.
Step 3: Create Java Class File in the src folder
Step 4: Set a system property “webdriver.chrome.driver” to the path of your ChromeDriver.exe file and instantiate a ChromeDriver class:
System.setProperty("webdriver.chrome.driver","C:\\Users\\ADMIN\\Documents\\chromedriver.exe"); ChromeDriver driver = new ChromeDriver();
Step 5: Write the code for opening the Google chrome and navigate to “geeksforgeeks.org”
Step 6: Now click on Run In eclipse IDE to execute the code
Please Login to comment...