Field-specific and page-level help messages should be available.
Language: Java
Framework: Selenium 4
1//Assuming webpage is a web application consisting of input fields and page level help messages2//Assuming help messages are displayed as a pop-up upon clicking a question mark icon next to input field or at the bottom of the page34import org.openqa.selenium.WebDriver;5import org.openqa.selenium.chrome.ChromeDriver;6import org.openqa.selenium.By;7import org.openqa.selenium.WebElement;89public class WebPageFunctionalityTest {1011public static void main(String[] args) {12System.setProperty("webdriver.chrome.driver", "path/to/chrome/driver");13WebDriver driver = new ChromeDriver();1415//Connecting to remote client with desired capabilities16/*17DesiredCapabilities capabilities = DesiredCapabilities.chrome();18String hubUrl = "http://10.0.0.10:4444/wd/hub";19WebDriver driver = new RemoteWebDriver(new URL(hubUrl), capabilities);20*/2122driver.get("http://www.example.com");2324//Checking for field-specific help messages25WebElement nameInput = driver.findElement(By.id("name"));26nameInput.click(); //To focus on input field27WebElement nameHelpMessage = driver.findElement(By.xpath("//div[@class='help-box'][contains(text(),'Enter your full name')]"));28if(nameHelpMessage.isDisplayed()){29System.out.println("Field-specific help message displayed for Name input field");30}31else{32System.out.println("Field-specific help message not displayed for Name input field");33}3435//Checking for page-level help messages36WebElement helpIcon = driver.findElement(By.className("help-icon"));37helpIcon.click(); //To open pop-up displaying page-level help messages38WebElement pageHelpMessage = driver.findElement(By.xpath("//div[@class='page-level-help'][contains(text(),'Please enter your details to create an account')]"));39if(pageHelpMessage.isDisplayed()){40System.out.println("Page-level help message displayed on webpage");41}42else{43System.out.println("Page-level help message not displayed on webpage");44}4546driver.quit();47}4849}
Language: Python
Framework: Selenium 4
1#Assuming the website has a Help button that displays field-specific and page-level help messages23from selenium import webdriver4from selenium.webdriver.common.keys import Keys56#Using local driver7driver = webdriver.Chrome()89#Connecting to remote client with desired capabilities10#uncomment to use remote driver11'''12from selenium.webdriver.common.desired_capabilities import DesiredCapabilities1314caps = DesiredCapabilities.CHROME.copy()15caps['platform'] = "WINDOWS"16caps['version'] = "10"17driver = webdriver.Remote(desired_capabilities=caps,18 command_executor="http://127.0.0.1:4444/wd/hub")19'''2021#Assuming the website url and the help button element22url = "https://www.example.com"23help_button_id = "help"2425#Navigate to the website26driver.get(url)2728#Click on the help button to display field-specific and page-level help messages29help_button = driver.find_element_by_id(help_button_id)30help_button.click()3132#Assert the presence of field-specific and page-level help messages33assert "Field-specific help message" in driver.page_source34assert "Page-level help message" in driver.page_source3536#Close the browser37driver.quit()
Language: Javascript
Framework: Cypress
1//Assuming the webpage is loaded and ready to test2//Assuming the field-specific and page-level help messages are marked by a '?' icon34describe('General webpage functionality', () => {5 it('should display field-specific and page-level help messages', () => {6 cy.visit('https://example.com') //replace URL with actual webpage link7 8 //locate all '?' icons on the page and click them9 cy.get('i.fa-question-circle')10 .each(($questionIcon) => {11 cy.wrap($questionIcon).click() //click each icon12 cy.get('div.help-message').should('be.visible') //confirm the help message is displayed13 })14 })15}) 1617//To connect to remote client with desired capabilities:18//Assuming the URL for the remote Selenium Grid is 'http://localhost:4444/wd/hub'1920describe('General webpage functionality', () => {21 it('should display field-specific and page-level help messages', () => {22 const desiredCapabilities = {23 browserName: 'chrome', //replace with desired browser24 platformName: 'Windows 10', //replace with desired OS 25 'goog:chromeOptions': {26 args: ['--start-maximized'] //replace with desired browser options27 }28 }2930 cy.visit('https://example.com', {31 browser: 'chrome',32 //replace 'localhost:4444' with actual IP address or hostname33 remoteHost: 'http://localhost:4444/wd/hub',34 desiredCapabilities35 })3637 //locate all '?' icons on the page and click them38 cy.get('i.fa-question-circle')39 .each(($questionIcon) => {40 cy.wrap($questionIcon).click() //click each icon41 cy.get('div.help-message').should('be.visible') //confirm the help message is displayed42 })43 })44})
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