Assignment 4
Assignment 4
Assignment 4
Veera Venkata Sai Kashyap Kaligotla
1 Selenium Setup
Setting up Selenium for our project involves several key steps. Firstly, we need to down-
load the Selenium Client & WebDriver Language Bindings for Java from the official
Selenium website. After extracting the downloaded ZIP file, we add the JAR files to our
Java project. We then download the appropriate WebDriver for our browser of choice,
such as ChromeDriver for Google Chrome, from the download pages. Once downloaded,
we place the WebDriver executable in a convenient location on our system. Next, we con-
figure our development environment, such as Eclipse IDE, by creating a new Java project
and adding the Selenium JAR files to the project’s build path. We set the WebDriver ex-
ecutable path in our code using the ‘System.setProperty‘ method. This configuration
ensures that our Selenium scripts can interact with the browser correctly. With these
steps completed, we are ready to write and execute our Selenium scripts to automate
browser tasks and perform web testing. This setup process lays the foundation for the
successful execution of the automated tasks outlined in the assignment.
2 Tasks:
This assignment involved the creation and execution of four specific Selenium tasks to
automate and verify various functionalities on the Amazon website.
// Go to cart
WebElement cart = driver . findElement ( By . id ( " nav - cart " ) ) ;
cart . click () ;
// Take a screenshot
File screenshot = (( TakesScreenshot ) driver ) .
getScreenshotAs ( OutputType . FILE ) ;
FileUtils . copyFile ( screenshot , new File ( " price_display . png
"));
driver . quit () ;
}
}
2
SE 5910 Assignment 4 Veera Venkata Sai Kashyap Kaligotla
Figure 1: Screenshot of the Output after I used Selenium to Verify the Correct Price
// Take a screenshot
File screenshot = (( TakesScreenshot ) driver ) .
getScreenshotAs ( OutputType . FILE ) ;
FileUtils . copyFile ( screenshot , new File ( "
coupon_code_option . png " ) ) ;
driver . quit () ;
3
SE 5910 Assignment 4 Veera Venkata Sai Kashyap Kaligotla
}
}
Figure 2: Screenshot of the Output after I used Selenium to Apply Coupun code task
// Increase quantity
WebElement quantityDropdown = driver . findElement ( By . name ( "
quantity " ) ) ;
4
SE 5910 Assignment 4 Veera Venkata Sai Kashyap Kaligotla
// Take a screenshot
File screenshot1 = (( TakesScreenshot ) driver ) .
getScreenshotAs ( OutputType . FILE ) ;
FileUtils . copyFile ( screenshot1 , new File ( "
quantity_increased . png " ) ) ;
// Decrease quantity
quantityDropdown . sendKeys ( " 1 " ) ;
// Take a screenshot
File screenshot2 = (( TakesScreenshot ) driver ) .
getScreenshotAs ( OutputType . FILE ) ;
FileUtils . copyFile ( screenshot2 , new File ( "
quantity_decreased . png " ) ) ;
driver . quit () ;
}
}
Figure 3: Screenshot of the Output after I used Selenium to Adjust quantity code task
5
SE 5910 Assignment 4 Veera Venkata Sai Kashyap Kaligotla
// Remove product
WebElement deleteButton = driver . findElement ( By . name ( "
submit . delete . CART_ITEM_ID " ) ) ;
deleteButton . click () ;
// Take a screenshot
File screenshot = (( TakesScreenshot ) driver ) .
getScreenshotAs ( OutputType . FILE ) ;
FileUtils . copyFile ( screenshot , new File ( " product_removed .
png " ) ) ;
driver . quit () ;
}
}
Figure 4: Screenshot of the Output after I used Selenium to Remove product task