Search code examples
seleniumgrailsgroovyspockgeb

Use string variable in geb selectors


I am testing my aplicaction using geb and spock frameworks. I have to check some dynamic fields that I generate their ID using DB info.

then:
String fieldID= "ID_34534_row"
assert $('\\#${fieldID}').displayed

this expression $('\#${fieldID}') is invalid

invalid selector: An invalid or illegal selector was specified

Could someone help me to find the correct selector expression?

Thanks in advance.


Solution

  • Should be

    assert $("#${fieldID}").displayed
    

    Shouldn't it?