Search code examples
seleniumxpathspockgeb

Send text to Text Field


How to send Text in text area field using geb & Spock?

Using just Selenium & the sendKeys I am able to send the text.

But unable to implement using geb spock.

this[field] = value - Not working

element.sendKeys(""); - Working


Solution

  • You probably want to look into the use of Geb Modules, particularly the Text Area module.

    Taken from the documentation:

    Given the html…

    <html>
        <body>
            <textarea name="language"/>
        </body>
    </html>
    

    It can be used this way…

    def textarea = $(name: "language").module(Textarea)
    textarea.text = "Groovy"
    
    assert textarea.text == "Groovy"