Exp 3 SY
Exp 3 SY
• It will redirect you to the "Download Packages" page. Click "Windows x86_64" under
"Eclipse IDE for Java Developers".
Developers" You can also select other
her options to download as per
the operating system you are using.
• Downloaded file will be in Zipped format. Unpack the contents to any drive or folder.
• Open "Eclipse" folder and click "Eclipse" (.exe file) to launch or open Eclipse IDE.
• Downloaded file will be in zipped format. Unpack the contents to some folder. It contains all
the jar files required to configure Selenium web driver in Eclipse IDE. Following selected
jar files and all jar files in "libs"
"libs" folder are required jar file and they will be added to the java
project in Eclipse IDE.
Test Scenario
Here, We will automate the testing for the following scenario in Google Chrome Browser by
developing Test Script using Selenium Web Driver:
Driver
We need unique id or name for required web elements (Name, Email,, Password and phone number
textboxes and check box)) to automate them through your test script. It can be done as follows:
Code Explaination
1. Open Eclipse application,, click "File -> New -> Java Project" and create Java project as
"ST Lab".
2. Right click on the "src" folder and create a new class file from the "New
New -> Class".
3. Give Class name as "Exp3"
"Exp3 and click the "Finish" buton.
4. Right click on the "src" folder and click "Build Path" ->
> "Configure Build Path".
5. Under Libraries tab, select "Classpath" and click "Add External JARs".
JARs" Then add all the
downloaded required JAR files ("client-combined-3.141.59.jar", " client-combined-3.141.59-
client
sources.jar", all jar files from "libs" folder and "junit4.jar" file) and finally click "Apply
and Close".
6. Import the required packages and set the system property "webdriver.chrome.driver" to
the path of your ChromeDriver.exe file.
System.setProperty("webdriver.chrome.driver",
("webdriver.chrome.driver", "D:\\STLab\\chromedriver.exe");
chromedriver.exe");
7. Create a instance of Web driver class, launch the browser and navigate it to the required
URL: accounts.lambdatest.com/register.
https://www.accounts.lambdatest.com/register Maximize the browser if
required.
8. Next, you need to locate the Name, Email, Password and phone
hone textbox elements and
Checkbox based on its unique name and send values as below:
driver.findElement(By.
.findElement(By.name("name")).sendKeys("Shiva");
driver.findElement(By.
.findElement(By.name("email")).sendKeys("[email protected]
[email protected]");
driver.findElement(By.
.findElement(By.name("password")).sendKeys("Test@123");
@123");
driver.findElement(By.
.findElement(By.name("phone")).sendKeys("1122447788
"1122447788");
driver.findElement(By.
.findElement(By.name("i_agree")).click();
9. "FREE SIGN UP" button located on the text of button and submit action is carried out using
following statement:
driver.findElement(By.
driver.findElement(By.xpath("//button[text()='Free Sign Up']")).submit();
']")).submit();
10. To validate results, assertions are needed. Asserts compares expected result with actual
result. Here, Expected URL on successful
succes login is https://accounts.lambdatest.com/email/verify.
It is compared with current actual URL as below:
Test Script
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Exp3 {
@Test
public void testRegForm()
{
//Set system property
System.setProperty("webdriver.chrome.driver", "D:\\STLab\\chromedriver.exe");
Test Result:
REFERENCES
[1] https://www.selenium.dev/
[2] https://www.javatpoint.com/selenium-webdriver
https://www.javatpoint.com/selenium
[3] https://www.tutorialspoint.com/selenium/selenium_webdriver.htm
[4] https://www.accounts.lambdatest.com/register
accounts.lambdatest.com/register