Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nightwatch - Meaning of WaitForElementVisible and WaitForElementPresent

Im using Nightwatch for e2e and Im finding these two command a little bit confusing given the name and explanation that comes with them.

.waitForElementVisible: Waits a given time in milliseconds for an element to be visible in the page before performing any other commands or assertions.

What is the meaning of visible?

  • An element position in the footer, you need to scroll to see it, is it considered visible?
  • Does it mean visible in the DOM even if it is display:hidden, position:relative; left:20000px;, ...? Not actually visible for a user but dom is existing basically.
  • What is a modal view in on top of some content? Is it visible?

.waitForElementPresent: Waits a given time in milliseconds for an element to be present in the page before performing any other commands or assertions.

What is the meaning of present?

  • Existing in the DOM without taking into account if it's visible or not?

Is there any relation/implication between these two command?

  • If an element return truth for .waitForElementVisible does it imply that .waitForElementPresent will return true?

A lot of questions but maybe an explanation about how they work would solve all of these small questions...

Sometimes Im just getting errors and Im thinking that it might be my bad understanding of these two commands.

like image 744
kitimenpolku Avatar asked Nov 09 '22 07:11

kitimenpolku


1 Answers

What is problem with definition ? You already answer your question.

An element position in the footer, you need to scroll to see it, is it considered visible?

  • No,you dont need to scroll to check it visible or not.May be you do need with some command but not with these visible/present commands.

Does it mean visible in the DOM even if it is display:hidden, position:relative; left:20000px;, ...? Not actually visible for a user but dom is existing basically.

  • Yes,it exists(means present) in the DOM but for some reason it is not visible yet (bad connection,attribute value,...).

If an element return truth for .waitForElementVisible does it imply that .waitForElementPresent will return true?

  • yes it will, if an element is visible = > it is present.

For usage , you can check out my an example answer here,it might help .

Login timeout

like image 164
Bao Tran Avatar answered Jan 04 '23 02:01

Bao Tran