I have faced this issue earlier. What I could understand is it could be due
to the network delays involved in loading the page sometimes. There are two
ways to avoid this based on my understanding.
1)  Dynamic sleep:
Something along the lines of this :
def sleep_while_id_not_present(element_id, print_string)
while !@browser.element(id: element_id).present? do
puts "sleeping 1 sec, whilst #{print_string}"
sleep 1
end
end
Although Beware that this could cause race issues of its own. Be careful
when using this.
2) You could get away using fire_event as it doesn't await confirmation.
    read here: fire_event
<https://www.rubydoc.info/gems/watir-webdriver/0.9.9/Watir%2FElement:fire_event>
Hope this helps!

Regards,
Sharat Oommen
On Tue, 6 Nov 2018 at 17:07, <rajagopalanmadas...@gmail.com> wrote:

> Hi Titus,
>
> I am facing weird problem,
>
> When I try to click the element, even after page arrives properly, it is
> waiting for 60 seconds and not clicking the button sometimes, it throws
> below error. but 4 out of 10 times it happens and rest of the time it runs
> successfully. What might be the problem? I never faced such a problem so
> far.
>
>
> Watir::Exception::UnknownObjectException: timed out after 60 seconds,
> waiting for #<Watir::HTMLElement: located: true; {:id=>"NavContinue"}> to
> be located
>
>   0) AGCSquoteCreation Test1
>      ?[31mFailure/Error: raise unknown_exception, msg?[0m
>      ?[31m?[0m
>      ?[31mWatir::Exception::UnknownObjectException:?[0m
>      ?[31m  timed out after 60 seconds, waiting for #<Watir::HTMLElement:
> located: true; {:id=>"NavContinue"}> to be located?[0m
>      ?[36m# ./Source/FrameWorkModules/Elements/Button.rb:15:in
> `waitAndClick'?[0m
>      ?[36m# ./Source/FrameWorkModules/Browser/Framework.rb:15:in `block in
> execute'?[0m
>      ?[36m# ./Source/FrameWorkModules/Browser/Framework.rb:11:in `each'?[0m
>      ?[36m# ./Source/FrameWorkModules/Browser/Framework.rb:11:in
> `execute'?[0m
>      ?[36m# ./Source/FrameWorkModules/Browser/PullTheTestCases.rb:16:in
> `call'?[0m
>      ?[36m# ./Source/Run_Spec.rb:40:in `block (4 levels) in <top
> (required)>'?[0m
>      ?[36m# ------------------?[0m
>      ?[36m# --- Caused by: ---?[0m
>      ?[36m# Watir::Wait::TimeoutError:?[0m
>      ?[36m#   timed out after 60 seconds, waiting for true condition on
> #<Watir::HTMLElement: located: true; {:id=>"NavContinue"}>?[0m
>      ?[36m#   ./Source/FrameWorkModules/Elements/Button.rb:15:in
> `waitAndClick'?[0m
>
> --
> --
> Before posting, please read
> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
>
> In short: search before you ask, be nice.
>
> watir-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com
> ---
> 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 watir-general+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to