Selector not working as expected

17 views
Skip to first unread message

Ben Frey

unread,
Aug 19, 2020, 4:29:00 PM8/19/20
to Geb User Mailing List
I'm starting a new project that logs in to my company's web site. I had an old project that I had working, but our pages have changed somewhat since then. I can use the browser console to select the element in question via
$$(".some-long-css-class")
(the element has a few other classes as well, but the browser still correctly finds the single element with that class). However, Geb does not find this class in my at method:

static at = { $('.some-long-css-class').text() == 'Welcome' }

this selector returns an empty array, so text() returns null. What could be going wrong here?

thok...@gmail.com

unread,
Aug 19, 2020, 4:36:24 PM8/19/20
to Geb User Mailing List
Hello Ben, 
possibly the element becomes available only after the page has completely finished loading.
You could try enabling "at-check waiting" or do something like

    waitFor {

        $('.some-long-css-class').text() == 'Welcome'   
    }

in your at-checker.

Does that work?

Thomas

Jeremy Cattau

unread,
Aug 19, 2020, 4:39:42 PM8/19/20
to geb-...@googlegroups.com
Can you post us the code or a screenshot of the DOM with the element in question?

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/c710b10a-7b24-4d0a-9d69-ecc23a0d2dffn%40googlegroups.com.

Ben Frey

unread,
Aug 19, 2020, 4:39:56 PM8/19/20
to Geb User Mailing List
That fixed it, thanks!
Reply all
Reply to author
Forward
0 new messages