Recreating instances is indeed what I'm trying to do. What I am finding challenging is recreating module instances that are content templates of a page. Do these get recreated when a page is browsed using Browser.to()? If Page transition doesn't involve a to() call, but rather, just an at() <https://groups.google.com/forum/#!topic/geb-user/YArbpe-aWzc>, will that affect the above?
On Friday, October 6, 2017 at 8:07:28 AM UTC+11, Marcin Erdmann wrote: > > No, there is no way to disable "caching" for #2 because it's explicit and > actually done by user code and not Geb code. > > I do not think that Geb is prickly with dynamic pages. I'm fairly certain > that you'd face similar issues using WebDriver. > > There are strategies to work around the problems you are facing. I > unfortunately wasn't able to come up with anything different than being > diligent and understanding which actions in your application and hence Geb > pages and modules cause asynchronous events to occur. I then wrap such > events in page or module methods which ensure that the asynchronous action > completes before the method returns by using a waitFor() call at the end of > the method. If an action causes a module base to be removed or replaced in > the DOM then that action unfortunately has to be implemented in the class > which contains a definition of that module so that the module instance can > be recreated without a StaleElementException being thrown. I can produce an > example of what I mean code if the explanation is not clear. > > Marcin > > On Wed, Oct 4, 2017 at 12:13 AM, Samuel Rossinovic <[email protected] > <javascript:>> wrote: > >> Is there a way to disable caching in case #2? >> >> My experience with geb so-far, is that it is quite prickly with dynamic >> pages. I may be able to interact with (module) content for the duration of >> a call, but then if I call the same method a second time, it will fail, >> citing "content not found". I keep being dumbfounded by cases where I >> believe my geb code is mirroring what I see in the browser, yet some >> underlying, invisible issue fails a test. >> >> >> On Monday, September 25, 2017 at 4:18:55 AM UTC+10, Marcin Erdmann wrote: >>> >>> Geb indeed evaluates templates on every call but there are multiple >>> situations when results of that evaluation are "cached" in the context of >>> what you're doing. To name three: >>> 1. Some operations are not atomic. What I mean by that is what looks >>> like a single Geb call results in multiple WebDriver calls. Take >>> $(".description").text() - it actually results in two calls, one to locate >>> the element(s) having description as the class and one to obtain the text >>> of that element. If the element is removed from the DOM in-between the two >>> calls you will get a StaleElementException. >>> 2. Geb's modules have a concept of base element. That element is located >>> when an instance of a module is created and "cached" for the lifetime of >>> that instance. So if you are calling any methods on instance of a module >>> and its base element has been removed from the DOM then you will get a >>> StaleElementException. >>> 3. If you assign elements returned from evaluation of content >>> definitions to a variable and then call multiple methods on that variable >>> then you are effectively "caching" that element in that context. If the >>> element is removed from the DOM between being assigned to the variable and >>> the method calls will get a StaleElementException. >>> >>> On Fri, Sep 22, 2017 at 12:46 AM, Samuel Rossinovic < >>> [email protected]> wrote: >>> >>>> I am confused about those exceptions I'm seeing on content elements. >>>> >>>> In Geb's manual, I read: >>>> >>>> cache >>>> >>>> Default value: false >>>> >>>> The cache option controls whether or not the definition is evaluated >>>> each time the content is requested >>>> >>>> So, if Geb evaluates content templates on every access, how can stale >>>> element exceptions occur? >>>> >>>> Thanks >>>> >>>> -- >>>> 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/38944bfb-daaf-4eac-a803-93583ea5e0bb%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/geb-user/38944bfb-daaf-4eac-a803-93583ea5e0bb%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> 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] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/geb-user/540478f0-3217-43d4-8ddc-8f90b280bd36%40googlegroups.com >> >> <https://groups.google.com/d/msgid/geb-user/540478f0-3217-43d4-8ddc-8f90b280bd36%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> 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/2eb37c21-5a54-4245-af39-9fb0ec3a28ea%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
