Why do you need button1 twice? Some thoughts:
- Assuming that button1 is always checked for visibility (no negative check), you can always wait for button1 without waiting for button2 if you make sure you always check for button2 (in)visibility after button1.
- OTOH, if you want the button2 check to be independent of button1 and you don't wait for button2 in the negative case, the test would pass even if button2 appears, just because you didn't wait for it. So then it would be better to always wait, depending on your test design. Testing for invisibility of asynchronously loaded page elements is always problematic because without waiting the test would pass too quickly and falsely!
- If you want to make your pages more test-friendly, you could always replace invisible elements by other elements (which do not eat screen space but are part of the DOM and accessible by your tests) and check explicitly for the existence of those (also waiting for them to appear, just like for regular elements). This way you always check for existing elements and do not speculate about non-existing ones. The only corner case remaining there would be that your application accidentally displays both the real and the marker element at the same time, in which case you would end up waiting for an invisible element. How far do you want to go there?
Having said that, in the meantime Marcin explained a better approach to handle waiting in general (putting it into at checkers and modules/pages and waiting explicitly).
[email protected] schrieb am 06.05.2019 20:46:
--No it wouldn't, but that statement would take your standard waiting timeout time to complete right?--Unless you specifybutton1{wait:false}so you end up withbutton1{wait: true}
button1_no_wait{wait: false}
or something similar if you also want to use button1 for anything that requires waitingOr am I missing something?
On Monday, May 6, 2019 at 1:57:43 PM UTC+2, Alexander Kriegisch wrote:Would it be asking too much to writebutton1.displayed && !button2.displayed--
Alexander Kriegisch-------- Ursprüngliche Nachricht --------Von: [email protected]Datum: 06.05.19 18:26 (GMT+07:00)An: Geb User Mailing List <[email protected]>Betreff: [geb-user] Verifying some elements are not displayedHi all,--I'm wondering how other people deal with the following scenario / what the best way for it is in Geb.Perhaps there exists some functionality already that I don't know of, perhaps more people run into this issue and we can add some functionality to geb.tldr: how do you optimally deal with !element_x.displayed cases. Especially when you prefer a wait:true for every action other than !displayed on that element/contentSample scenario- I have a button- For some tests I want to click that button, in general, it's nice to define 'wait: true' so that it waits for that button to appear before pressing it.(because I won't want to describe everything in my POM or because the button is dynamically loaded)- For some tests, I want to make sure that button is not displayedProblem:
- I don't want to wait the full default timeout duration to assess that the button in fact, did not show up. But I also don't want to put an arbitrary '2 seconds' on it either, it's also too slow and maybe on some CI tooling it can actually take those 2 seconds to load causing tests that randomly succeed or fail- I want to make the tests as fast as possible. To do this, generally, I wait for some other element that should be displayed at the same time as the element in question, then I usually do: !element_x.displayed with wait time 0.But: I don't want to define that (geb) content twice, once with wait: true, once with wait: false (or wait: 2)Possible solutions I've thought of:- Would be nice to be able to manually specify a specific wait time inside the tests when using a geb module's content.So f.e.: for that element, when declaring it in its geb module's content, the (default) wait time is set to true. But when calling that content from inside the test, I can set a specific wait time of 0- Instead of 'wait: true', I could f.e. mention an other piece of content as an element to wait for (instead of a time duration). I can do this when I know that an element is loaded at the same time as that other piece of content.Example: Let's say I have button1 and button2, they're both dynamically loaded at the same time but button 2 should only display when the user .f.e. has admin rights, then I can link button2's 'waiting time' to button1.When I do f.e. in my test: !button2.displayed it can automatically wait for button1 to appear, then it can verify whether button2 is displayed as well, and, if not, automatically throw an exception
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-...@googlegroups.com .
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/a219b54d-6feb- .449f-b75a-ae07e5b7f7fa% 40googlegroups.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/7da8d5e3-9845-4d7e-bbea-ed816db54e92%40googlegroups.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/20190508023244.889CC44C1352%40dd39516.kasserver.com.
For more options, visit https://groups.google.com/d/optout.
