Confirmation messages should be displayed before performing any updates or deleting operations.
Language: Java
Framework: Selenium 4
1//Assuming the webpage is already loaded and confirmation messages are implemented on the webpage2//Connecting to local driver3WebDriver driver = new ChromeDriver();45//Connecting to remote client with desired capabilities6/*DesiredCapabilities capabilities = DesiredCapabilities.chrome();7capabilities.setCapability("platform", "Windows 10");8capabilities.setCapability("version", "91.0");9capabilities.setCapability("name", "Verify confirmation message display"); //Assuming the test name is required for remote client report10WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4445/wd/hub"), capabilities);*/1112//Locating the element which displays confirmation message13WebElement confirmationMessage = driver.findElement(By.id("confirmationMessage"));1415//Verifying the display of confirmation message16if(confirmationMessage.isDisplayed()) {17 System.out.println("Confirmation message displayed successfully");18}19else {20 System.out.println("Confirmation message not displayed");21}2223//Closing the driver24driver.quit();
Language: Python
Framework: Selenium 4
1from selenium import webdriver2from selenium.webdriver.common.keys import Keys34#Assuming the user is using Chrome Webdriver in the local system5#Replace the path to the chromedriver.exe file in the line below based on your system6driver = webdriver.Chrome('path_to_chromedriver.exe')78#Code for connecting to remote client with desired capabilities9#Assuming the user wants to run the test on Firefox browser on a remote client10#from selenium.webdriver.common.desired_capabilities import DesiredCapabilities11#caps = DesiredCapabilities.FIREFOX12#driver = webdriver.Remote(13#command_executor='remote_client_IP_address:port/wd/hub',14#desired_capabilities=caps15#)1617#Navigate to the webpage to be tested18driver.get("https://example.com")1920#Locate the element that displays confirmation message21confirmation_message = driver.find_element_by_id("confirmation_message")2223#Check if the confirmation message is displayed24if confirmation_message.is_displayed():25 print("Confirmation message displayed successfully!")26else:27 print("Confirmation message not displayed.")2829#Close the browser window30driver.close()
Language: Javascript
Framework: Cypress
1// Assumptions:2// - The website under test has a confirmation message element with id 'confirmation-msg'3// - The confirmation message element is hidden by default and only displayed when updates or deletions are made45describe('General Webpage Functionality Test', () => {6 it('Verify Confirmation Message Display', () => {7 // Navigate to the webpage under test8 cy.visit('https://www.example.com');910 // Click on a button that triggers an update or deletion operation11 cy.get('#update-btn').click();1213 // Wait for the confirmation message element to be displayed14 cy.get('#confirmation-msg').should('be.visible');1516 // Assert that the confirmation message is displayed with the correct text17 cy.get('#confirmation-msg').should('have.text', 'Are you sure you want to perform this operation?');1819 // Connect to remote client with desired capabilities (uncomment and update desired capabilities as necessary)20 //cy.visit('https://www.example.com', {21 //chromeWebSecurity: false,22 //headless: true,23 //disableGpu: true,24 //defaultCommandTimeout: 1000025 //});26 });27});
Disclaimer: Following code snippets and related information have been sourced from GitHub and/or generated using AI code generation tools. LambdaTest takes no responsibility in the accuracy of the code and is not liable for any damages.
Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.
Test Intelligently and ship faster. Deliver unparalleled digital experiences for real world enterprises.
Start Free Testing