Hi Martin,
The problem you describe is quite common, at least I come across it quite
frequently, especially in single page apps.
The way I deal with it is to not use the element that is removed from the
DOM as the base for the module but use the closest parent element which is
not removed from DOM as part of interactions with the module in question.
So I would have something like:
class DynamicModule extends Module {
static content = {
root { /*whatever selects what is now your module base and what
gets removed from the DOM after clicking it*/ }
}
void open() {
root.click()
waitFor { root }
// double click root, however that's implemented
waitFor { root }
}
}
But I wish to hide all this from the test itself, that's what geb is for
> right?
>
That is indeed the intent. It makes me very happy that others see it as
well.
> 1) Use some sort of this.refresh() command (does it exist?)
>
No, it doesn't exist. And it would not be possible the way things are
implemented. But your need for it makes me think that we should have
auto-refresh modules in Geb - ones for which the base element is calculated
every time base is requested and not only at module creation time and then
cached. This will be a significant change to how things are structured in
Geb so it might be a while until it's implemented. I've created an issue
for this: https://github.com/geb/issues/issues/557
> 2) Move this method to the page object, and re-'instantiate' the geb
> module from there inbetween.
>
That's indeed another approach but it suffers from bad encapsulation - the
page object shouldn't now about the internals of the module and if you need
to use the same module from another page you will have to duplicate that
code.
--
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%2B52dQTQkwGN1DSGq1O7XRRdavT%3DuVR9UHGO%2BfY7tji9jHRuWw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.