Selenium Program to Login to a Specific Web Page
Tip: One should be well versed with Eclipse and JDK understanding concepts.
- Create New Project, Click on File
- Create a new java class
- Download the latest Chrome Driver and Selenium Web Driver for Java
- Click on Classpath and Select Add External JARs.
These above steps are as depicted below with help of visual aids for better understanding.
Step 1: To Create New Project, Click on File –> New –> Java Project.
After creating a new project, give the project name “Login_Test” and click on Finish.
Step 2: Create a new java class
For creating a new Java class, Right-click on “Test”, Click on new and select Class. Given the class name “Login_test” and click Finish.
Now we have to import Selenium Web Driver and Chrome Driver.
Step 3: Download the latest Chrome Driver and Selenium Web Driver for Java. After downloading, unzip the downloaded files. Right-click on “Testing”, Click on Build Path, and Select Configure Build Path.
Step 4: Click on Classpath
4.1: Initially alongside select Add External JARs.
4.2: Now go to the Selenium driver downloaded file, select both these jar files and click on ‘Open’.
4.3: Go to the same folder, open the “libs” folder, select all the jar files, and click on ‘Open’.
After adding all these required Jar files, below is the given code to test the login page.
After adding this code, click on the ‘Run’ button.
Chrome Driver will start successfully and Chrome browser will open. It will automatically open the GeeksforGeeks login page and add details for login. If the details are valid, it will redirect to its website.
Please Login to comment...