oliyh / kamera

UI testing via image comparison and devcards
89 stars 7 forks source link

wait timeout for rendering needs to be configurable #35

Open jleonard-r7 opened 3 years ago

jleonard-r7 commented 3 years ago

Hi,

I have a situation where the following wait is not long enough (for a "default" google maps devcard). The render proceeds because devcard elements are present and the following sleep expires but the actual rendered bits are in an in-between state where the render is clearly not complete and the colors are kinda grayed out (seems that google maps must come in as a sort of gradient animation).

https://github.com/oliyh/kamera/blob/085b2df3d28d2f828933f5a643b04952b34e440d/src/clj/kamera/core.clj#L222

What do you suggest for this situation?

jleonard-r7 commented 3 years ago

(This obviously is an intermittent failure. Many times the render has in fact completed in that timeframe and thus matches the reference image).

oliyh commented 3 years ago

Hi,

Have you tried the :ready? predicate? From the README: :ready? (fn [session] ... ) ;; predicate that should return true when screenshot can be taken

https://github.com/oliyh/kamera/blob/085b2df3d28d2f828933f5a643b04952b34e440d/src/clj/kamera/core.clj#L219-L220

You can implement it to execute some javascript and try to determine if it's ready or not.

jleonard-r7 commented 3 years ago

We have 50 devcards. The default devcard ready? is fine for 49 of them. As far as I know it isn’t possible to override ready? for just one of the devcards.

oliyh commented 3 years ago

Hello,

Yes, if you are using the kamera.devcards namespace you can provide this extra option as per the reader:

:on-targets (fn [targets] ... )} ;; function called to allow changing the targets before the test is run

This will let you set the ready? fn for your specific devcard. The alternative is, in your generic ready? fn to look for the presence of a Google maps div and wait for it to be ready if it finds one.