Search code examples
javaseleniumselenium-webdriverxpathsendkeys

How to pass multiple values in different lines using sendKeys() inside a text box


I wanted to pass multiple words in different line on to text box, can anyone help me finding out the solution

Expected output :

13456,Teena
12378,Tesa
130987,Jhon

Solution

  • textbox.sendKeys("13456,Teena" + Keys.SHIFT + Keys.ENTER + "12378,Tesa" + Keys.SHIFT + Keys.ENTER + "130987,Jhon");

    Use Keys.SHIFT + Keys.ENTER combination to the sendKeys() method.

    Similarly, we can use Keys enum for different non-text keys and pass them to the sendKeys method. The following table has an entry for each of the non-text key present in a keyboard.

    Refer - https://artoftesting.com/press-enter-tab-space-arrow-function-keys-in-selenium-webdriver-with-java