#present? is literally making a #visible? call and rescuing the exception if the element is not present, so it is exactly what you are looking for if you want to check if an element is both in the DOM and displayed on the page. I rarely have occasion to use #visible? since #present? is almost always the better option.
https://github.com/watir/watir/blob/master/lib/watir/elements/element.rb#L392-L396 On Thursday, March 23, 2017 at 12:03:36 PM UTC-5, Raja gopalan wrote: > > I don't believe both method is doing same Job, because .present check > whether a particular element is over showed by other elements. > > On Thu, Mar 23, 2017 at 10:00 AM, 'John Fitisoff' via Watir General < > [email protected] <javascript:>> wrote: > >> try .present? instead >> >> >> ------------------------------ >> *From:* Raja gopalan <[email protected] <javascript:>> >> *To:* [email protected] <javascript:> >> *Sent:* Thursday, March 23, 2017 9:52 AM >> *Subject:* [wtr-general] Exist method is needed while I use visible >> method, Can it be avoided? >> >> I find I couldn't use visible method without exists method because >> visible method throws the error if element is not present. Though it seems >> to be logically correct, it doesn't give the practical easiness, for an >> example, >> >> I can't write >> >> *If element.visible?* >> >> instead I need to write >> >> *If element.exists? and element.visible? * >> >> I always need to include the exists method call while I use visible >> method call, So can this method be changed to return true or false >> according to whether it is visible or not visible? >> >> -- >> Rajagopalan >> -- >> -- >> Before posting, please read http://watir.com/support. In short: search >> before you ask, be nice. >> >> [email protected] <javascript:> >> http://groups.google.com/group/watir-general >> [email protected] <javascript:> >> >> --- >> You received this message because you are subscribed to the Google Groups >> "Watir General" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> >> >> -- >> -- >> Before posting, please read http://watir.com/support. In short: search >> before you ask, be nice. >> >> [email protected] <javascript:> >> http://groups.google.com/group/watir-general >> [email protected] <javascript:> >> >> --- >> You received this message because you are subscribed to the Google Groups >> "Watir General" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Rajagopalan > -- -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected] --- You received this message because you are subscribed to the Google Groups "Watir General" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
