Brian,
One thing that I don't understand is why you see a different behaviour if
the condition is fulfilled (i.e. there is no StaleElementReferenceException)
and when it is not. Is it the case that the value of the date field does
not change when your test passes? The fact that you are getting the
exception stems most probably from the fact that the DOM is still updating
while the condition is being checked.
A slightly better way of avoiding the exception would be to wrap the
extraction of the element value in a waitFor:
waitFor { labRequest[0].dateField.value() } == requestDate
This way you will utilise the fact that waitFor() retries if there is an
exception thrown from the closure passed to it.
Anyhow you should probably use a better wait for condition to wait for the
page to stabilise after performing the action that triggers DOM updates.
The one you shared previously, that is waitFor { labRequest[0].labNameField.
value() }, clearly did not work given the behaviour you observed after
introducing it.
On Thu, Aug 18, 2016 at 11:45 PM, Brian Westrich <[email protected]> wrote:
> Brian,
>
> You are right that the expected value is listed in the debug output.
>
> What's curious is that, when the comparison (between actual and
> expected values) fails, I only see the expected value if I use a
> waitFor() as suggested by Marcin. If I don't use waitFor(), I instead
> get a StaleElementReferenceException and the expected value isn't
> shown (though, as noted previously, if the comparison succeeds, the
> waitFor isn't needed for the test to pass).
>
> Another curiousity: If I pass in a smaller value for the timeout (say
> 1 second), geb still shows the expected value on failure, but I don't
> have to wait the default duration of 30 seconds. Instead, Geb shows
> the expected value after only 1 second of waiting:
>
> waitFor(1) {
> labRequest[0].dateField == requestDate
> }
>
> Output:
>
> condition did not pass in 1.0 seconds (failed with exception)
> geb.waiting.WaitTimeoutException: ......
> ...
> Caused by: Assertion failed:
>
> labRequest[0].dateField == requestDate
> | | | | |
> | | | | 2016-03-02T00:00
> | | | false
> | | dateField - SimplePageContent (owner: labRequest -
> LabAnalysisRequestRow (owner: ProjectDetailPage, args: [], value:
> null), args: [], value: 2016-02-03T00:00)
> | labRequest - LabAnalysisRequestRow (owner:
> ProjectDetailPage, args: [], value: null)
> [labRequest - LabAnalysisRequestRow (owner: ProjectDetailPage, args:
> [], value: null)]
>
> So it looks like, in this case, some waiting period is needed before
> geb is able to fully report test error information, but not for geb to
> process a successful comparison.
>
> Incidentally, I thought this behavior might only be occurring for date
> fields, but have verified it occurs for other types of fields as well
> (e.g. string).
>
> Brian W.
>
> On Thu, Aug 18, 2016 at 1:41 PM, Brian Kotek <[email protected]> wrote:
> > Isn't the answer right there in the debug output? The value of dateField
> is
> > "2016-02-03T00:00" but the value of requestDate is "2016-03-02T00:00".
> They
> > aren't equal, so the assertion failure is correct.
> >
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/geb-user/CAMvxi929qMA-5ERFoOXH4BTiHU7eQe_wQJPJc0aEEhDYzbZz8A%40mail.
> gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/geb-user/CA%2B52dQQyruu4Gskdd16uu-5Gq9qZnXyVKuLX3-%2BNyH1NFBHpDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.