Se2 Exp8
Se2 Exp8
Reg No - 221070071
Experiment - 8
Aim:
To automate web browser interactions using Selenium for tasks such as form
submission, web scraping, testing web applications, and validating UI behavior.
Theory:
Selenium is an open-source automation tool used for controlling web browsers through
programs and performing browser-based automation. It supports various programming
languages like Python, Java, C#, and JavaScript and is compatible with major browsers
such as Chrome, Firefox, Safari, and Edge.
1. Selenium WebDriver – Provides APIs to interact with web elements and control
the browser programmatically.
3. Selenium Grid – Used to run tests on different machines and browsers in
parallel.
Code -
console.log("Location entered");
// Property Tags
const tagsField = await findElement(driver, [
By.css('input[placeholder*="Product Tags" i]'),
]);
await tagsField.clear();
await tagsField.sendKeys("Furnished");
console.log("Tags entered");
// BHK
const bhksField = await findElement(driver, [
By.css('input[placeholder*="Product Bhks" i]'),
]);
await bhksField.clear();
await bhksField.sendKeys("3BHK");
console.log("BHKs information entered");
// Price
const priceField = await findElement(driver, [
By.id("price"),
By.css('input[placeholder*="$2999" i]'),
]);
await priceField.clear();
await priceField.sendKeys("25000");
console.log("Price entered");
// Category (Star Rating)
const categorySelect = await findElement(driver, [
By.id("category"),
By.css("select:nth-of-type(1)"),
]);
await driver.executeScript("arguments[0].click();", categorySelect);
await driver.sleep(500);
await driver.executeScript("arguments[0].value = '5';", categorySelect);
console.log("Selected 5-star rating");
// Amenities
const amenitiesSelect = await findElement(driver, [
By.id("amenities"),
By.css("select:nth-of-type(2)"),
]);
await driver.executeScript("arguments[0].click();", amenitiesSelect);
await driver.sleep(500);
await driver.executeScript("arguments[0].value = '1';", amenitiesSelect);
Denish Suhagiya
Reg No - 221070071
Output -
Denish Suhagiya
Reg No - 221070071
Denish Suhagiya
Reg No - 221070071
Conclusion:
Selenium proves to be a powerful and flexible tool for web automation and testing. Its
cross-browser and cross-platform support, combined with its ability to integrate with
various programming languages and frameworks, makes it ideal for end-to-end testing
of web applications. Through practical implementation, users gain hands-on experience
with automated workflows, improving the reliability and scalability of web-based
systems.