# Readystate\_complete = 	4

**URL:** <https://www.ruby-forum.com/t/readystate-complete-4/169486>\
**Category:** Ruby\
**Created:** [June 4, 2009, 11:05am UTC](https://www.ruby-forum.com/t/readystate-complete-4/169486 "2009-06-04T11:05:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e495f1/32.png) [@beginner](https://www.ruby-forum.com/u/beginner)\
**Post date:** [June 4, 2009, 11:05am UTC](https://www.ruby-forum.com/t/readystate-complete-4/169486/1 "2009-06-04T11:05:14Z")

</div>

I am trying to use this but not sure how to implement it. I just want to  
check after x seconds if page is loading so was trying something like:

```
sleep (10)

pageCheck = READYSTATE_COMPLETE = 4

if pageCheck = true
  puts 'test passed'
else
  puts 'epic fail'
  end

```

Any ideas where I am going disasterously wrong?

---

<div class="post-metadata">

**Author:** ![beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e495f1/32.png) [@beginner](https://www.ruby-forum.com/u/beginner)\
**Post date:** [June 4, 2009, 11:43am UTC](https://www.ruby-forum.com/t/readystate-complete-4/169486/2 "2009-06-04T11:43:22Z")

</div>

Jerry Lane wrote:

> ```
> puts 'epic fail'
> end
> 
> ```
> 
> Any ideas where I am going disasterously wrong?

‘=’ is for assignment, ‘==’ is for comparison.

sleep (10)

pageCheck = READYSTATE\_COMPLETE = 4 # This sets pageCheck and  
READYSTATE\_COMPLETE to 4

if pageCheck = true # This sets pageCheck to true  
puts ‘test passed’  
else  
puts ‘epic fail’  
end

It’s hard to tell exactly what you are trying to do, but I _think_ you  
want something more like

if READYSTATE\_COMPLETE == 4  
puts ‘test passed’  
else  
puts ‘epic fail’  
end

or if you need pageCheck later

pageCheck = READYSTATE\_COMPLETE == 4

if pageCheck  
puts ‘test passed’  
else  
puts ‘epic fail’  
end

-Justin

---

<div class="post-metadata">

**Author:** ![beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e495f1/32.png) [@beginner](https://www.ruby-forum.com/u/beginner)\
**Post date:** [June 4, 2009, 12:17pm UTC](https://www.ruby-forum.com/t/readystate-complete-4/169486/3 "2009-06-04T12:17:01Z")

</div>

when I try this I get the following:

test\_00009\_Bug4986\_error\_on\_dialog\_close(DocumentTestScripts):  
NameError: uninitialized constant  
DocumentTestScripts::READYSTATE\_COMPLETE  
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active\_support/dependencies.rb:105:in  
`const_missing' test_Bug4986.rb:42:in`test\_00009\_Bug4986\_error\_on\_dialog\_close’

It is actually a type of Watir test I am trying to run which checks if  
the page displays done (as in fully loaded) in the bar on the bottom of  
the window but I cant get it to work ☹

---

<div class="post-metadata">

**Author:** ![beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e495f1/32.png) [@beginner](https://www.ruby-forum.com/u/beginner)\
**Post date:** [June 4, 2009, 12:49pm UTC](https://www.ruby-forum.com/t/readystate-complete-4/169486/4 "2009-06-04T12:49:17Z")

</div>

Jerry Lane wrote:

> It is actually a type of Watir test I am trying to run which checks if  
> the page displays done (as in fully loaded) in the bar on the bottom of  
> the window but I cant get it to work ☹

You might want to ask on the Watir mailing list, then:  
[http://groups.google.com/group/watir-general?pli=1](http://groups.google.com/group/watir-general?pli=1)

But the previous code is not going to work - you need to get the  
readyState from the Watir::IE object and compare that to  
READYSTATE\_COMPLETE (which is 4): [http://wtr.rubyforge.org/rdoc/](http://wtr.rubyforge.org/rdoc/)

-Justin
