The description text box should be multi-lined.
Language: Java
Framework: Selenium 4
1//Assuming the website is already launched and driver is initialized.2//Assuming the description text box is located using its name or ID attribute.34//Test case to verify multi-line description text box functionality.56@Test7public void testMultiLineDescriptionTextBox() {8 WebElement descriptionTextBox = driver.findElement(By.id("descriptionTextBox"));9 String testDescription = "This is a test description text.\nLine1\nLine2\nLine3";10 boolean multiLine = false;1112 //Enter the test description text13 descriptionTextBox.sendKeys(testDescription);1415 //Check if the description field is multi-line16 if(descriptionTextBox.getAttribute("value").contains("\n")){17 multiLine = true;18 }1920 //Verify if the description text is multi-line21 Assert.assertTrue(multiLine);2223 //Clear the text box for future usage24 descriptionTextBox.clear();25}2627//Code to connect to a remote client with desired capabilities:28//Assuming the remote client has already initiated a session with the capabilities.29WebDriver driver = new RemoteWebDriver(new URL("remote client URL"), DesiredCapabilities.chrome());30//Replace "chrome" with the desired browser name.
Language: Python
Framework: Selenium 4
1#Assuming the webpage is already open and we are on the required page23from selenium import webdriver4from selenium.webdriver.common.keys import Keys56#To use local driver:7driver = webdriver.Chrome()8#To connect to remote client with desired capabilities:9#Create a dictionary of required capabilities10#caps = {'browserName': 'chrome', 'version': '76.0', 'platform': 'Windows10', 'javascriptEnabled': True}11#Create a webdriver object with remote URL and desired capabilities12#driver = webdriver.Remote(command_executor='http://localhost:4444/wd/hub', desired_capabilities=caps)1314#Locate description text box element by its id15desc_box = driver.find_element_by_id('description_box')16#Assuming the text has already been entered in the text box17#Checking if the text entered is multi-lined18if '\n' in desc_box.get_attribute('value'):19 print('Test passed: Multi-lined description text box works as expected')20else:21 print('Test failed: Description text box is not multi-lined')2223#Close the driver24driver.quit()
Language: Javascript
Framework: Cypress
1//Assuming that the webpage is already loaded and the description text box is in focus23describe('Test multi-line description text box', () => {4 5 it('should allow multiple lines of text to be entered into the description text box', () => {6 7 //Assuming that the description text box can be identified by an id attribute8 cy.get('#description-text-box')9 10 //Assuming that the description text box already has some text in it11 .type('This is the first line of text in the description box.')12 13 //Assuming that the 'Shift' key + 'Enter' key can be used to create a new line in the description box14 .type('{shift}{enter}This is the second line of text in the description box.')15 16 //Assuming that the text in the description box can be verified using a class attribute17 .should('have.class', 'multi-line');18 });19 20});2122//Assuming that the code to connect to a remote client with desired capabilities is as follows:2324describe('Test multi-line description text box', () => {25 26 before(() => {27 cy.visit('http://example.com', {28 //Assuming that the desired capabilities include a specific browser type and version29 browser: 'chrome',30 browserVersion: '96.0',31 });32 });33 34 it('should allow multiple lines of text to be entered into the description text box', () => {35 36 //Assuming that the description text box can be identified by an id attribute37 cy.get('#description-text-box')38 39 //Assuming that the description text box already has some text in it40 .type('This is the first line of text in the description box.')41 42 //Assuming that the 'Shift' key + 'Enter' key can be used to create a new line in the description box43 .type('{shift}{enter}This is the second line of text in the description box.')44 45 //Assuming that the text in the description box can be verified using a class attribute46 .should('have.class', 'multi-line');47 });48 49});
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