Upon clicking on the input text field, the mouse arrow pointer should get changed to the cursor.
Language: Java
Framework: Selenium 4
1// Assuming that the page has a web form with an input text field2// Assuming that Selenium 4 and its dependencies have been properly installed34import org.openqa.selenium.By;5import org.openqa.selenium.WebDriver;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.chrome.ChromeDriver;89public class VerifyCursorOnInputTextField {1011 public static void main(String[] args) {1213 // Set up the Chrome driver (local)14 System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");15 WebDriver driver = new ChromeDriver();1617 // Set desired capabilities and connect to remote client (commented out)18 // DesiredCapabilities capabilities = DesiredCapabilities.chrome();19 // WebDriver driver = new RemoteWebDriver(new URL("http://remoteclienturl:4444/wd/hub"), capabilities);2021 // Navigate to the page with the input text field22 driver.get("https://www.example.com/form");2324 // Find the input text field and click on it25 WebElement inputTextField = driver.findElement(By.id("input-text-field"));26 inputTextField.click();2728 // Verify that the cursor has changed to the text input cursor29 String cursorType = inputTextField.getCssValue("cursor");30 if (cursorType.equals("text")) {31 System.out.println("The cursor on the input text field has changed to the text input cursor");32 } else {33 System.out.println("The cursor on the input text field has not changed to the text input cursor");34 }3536 // Close the browser window37 driver.quit();38 }3940}
Language: Python
Framework: Selenium 4
1# Assumptions:2# - The webpage is loaded and the input text field is visible3# - The input text field has a unique ID of "input-field"45from selenium.webdriver import Chrome, ChromeOptions6from selenium.webdriver.common.by import By7from selenium.webdriver.support.ui import WebDriverWait8from selenium.webdriver.support import expected_conditions as EC910# Local driver initialization11driver = Chrome()1213# Remote client with desired capabilities initialization (commented out)14#options = ChromeOptions()15#options.add_argument('--headless')16#options.add_argument('--disable-gpu')17#driver = webdriver.Remote(18# command_executor='http://localhost:4444/wd/hub',19# options=options,20# desired_capabilities=DesiredCapabilities.CHROME)2122try:23 # Open the webpage24 driver.get("http://example.com")2526 # Wait for the input text field to be clickable27 input_field = WebDriverWait(driver, 10).until(28 EC.element_to_be_clickable((By.ID, "input-field"))29 )3031 # Click the input text field to activate it32 input_field.click()3334 # Verify that the cursor changes to the text insertion cursor (|) by checking the CSS cursor property35 assert input_field.value_of_css_property("cursor") == "text"3637 print("Test passed.")38finally:39 driver.quit()
Language: Javascript
Framework: Cypress
1describe('General webpage functionality', () => {2 it('Verify cursor on input text field', () => {3 // Assuming we are testing on a web app with input text fields4 // This test case will focus on a single text field5 cy.visit('https://www.example.com')6 // Provide an id or class to the input text field element 7 cy.get('#input-text-field-id').click()8 .should('have.css', 'cursor')9 .and('eq', 'text'); 10 11 // To run the test case on remote client with desired capabilities12 // Follow the instructions given on the Cypress documentation page13 // https://docs.cypress.io/guides/guides/continuous-integration.html#Advanced-Configuration14 // The code would look like this -15 16 // cypress.json file17 {18 "projectId": "<your-project-id>",19 "env": {20 "browser": "<custom browser>",21 "baseUrl": "<url to remote client>"22 }23 }24 25 // spec.js file26 describe('General webpage functionality', () => {27 it('Verify cursor on input text field', () => {28 cy.visit('/')29 cy.get('#input-text-field-id').click()30 .should('have.css', 'cursor')31 .and('eq', 'text');32 });33 });34 });35});
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