# Question on watir

**URL:** <https://www.ruby-forum.com/t/question-on-watir/224437>\
**Category:** Ruby\
**Created:** [November 12, 2012, 5:45am UTC](https://www.ruby-forum.com/t/question-on-watir/224437 "2012-11-12T05:45:39Z")\
**Posts on this page:** 20\
**Page:** 6

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 14, 2013, 5:23am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/101 "2013-03-14T05:23:39Z")

</div>

hi, thank you, I am using the version of 1.8.3 version, But if i use the  
1.9.3,I am facing the problem gem installation, So i never go there.

RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 14, 2013, 7:44am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/102 "2013-03-14T07:44:48Z")

</div>

Am 14.03.2013 05:23, schrieb Raj pal:

> hi, thank you, I am using the version of 1.8.3 version, But if i use the

Any support for 1.8.7 (like security fixes) will end this year.

> 1.9.3,I am facing the problem gem installation, So i never go there.

?

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 14, 2013, 7:59am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/103 "2013-03-14T07:59:14Z")

</div>

I have already in a project for automation,now all functions are working  
in 1.8.7 ,So if i immediately changes to 1.9.7,I will be in need of  
changing everything right?

RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 14, 2013, 8:44am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/104 "2013-03-14T08:44:33Z")

</div>

hi, I am comparing objects like

if a.class.to\_s == ‘hash’  
puts ‘hash’  
end

Is there any way can i compare objects directly?

Like if a.class==OBJECT  
puts ‘hash’  
end

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 14, 2013, 10:06am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/105 "2013-03-14T10:06:32Z")

</div>

object.is\_a?( Hash ) is the one I usually use.

By the way, this caught me out for a while. When using a case statement  
to check classes, the syntax is a bit different from if statements:

case object  
when Hash  
end

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 14, 2013, 9:28am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/106 "2013-03-14T09:28:15Z")

</div>

On Mar 14, 2013 2:45 AM, “Raj pal” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> puts 'hash'
> 
> ```
> 
> end
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Not quite getting what you want, but would === or is\_a? work?

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 14, 2013, 1:15pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/107 "2013-03-14T13:15:09Z")

</div>

hi I have a question about pop up, we can handle the pop up if it is the  
part of the window. But Now I am automating another screen,here pop up  
arises as new window, how can i handle this pop up? Is there any idea?

RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 14, 2013, 1:38pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/108 "2013-03-14T13:38:30Z")

</div>

This was already addressed in another thread:  
[http://www.ruby-forum.com/topic/4407617#new](http://www.ruby-forum.com/topic/4407617#new)

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 14, 2013, 1:47pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/109 "2013-03-14T13:47:11Z")

</div>

Ok Thank you very much.

RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 18, 2013, 10:44am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/110 "2013-03-18T10:44:56Z")

</div>

hi Joel P.,

a="hi how are you

what are you doing"

b="hi how are you

what are you doing"

one=a  
one=one.delete(’ ‘)  
one=one.delete("\n")  
puts one  
two=b  
two=two.delete(’ ')  
two=two.delete("\n")  
puts two

The above code is working perfectly, but while i take “hi how are you  
what are you doing” from SCREEN to a variable one,this delete("\n") is  
not working, can you guess where the problem is?

RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 14, 2013, 11:04am UTC](https://www.ruby-forum.com/t/question-on-watir/224437/111 "2013-03-14T11:04:23Z")

</div>

yes it is working for me, this is what I want.And what is the difference  
did you see while you were using for case statement.?

Thank you.  
RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 18, 2013, 12:22pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/112 "2013-03-18T12:22:38Z")

</div>

Yes thank you, I realized that that character was 13 not 10.10 is for  
enter key.That’s what it hasn’t been removed. Thanks anyway for this a =  
a.gsub(/\s/,’’)code.

RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 18, 2013, 12:13pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/113 "2013-03-18T12:13:31Z")

</div>

Inspect the result you get from “SCREEN”. You may have different  
characters in there.

By the way, if you really feel the urge to remove all whitespace, try  
this:

a = a.gsub(/\s/,’’)

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 18, 2013, 1:14pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/114 "2013-03-18T13:14:28Z")

</div>

It means that 1.8.7 won’t receive any more updates, so you need to  
upgrade to a newer Ruby version ASAP.  
I’d reccommend testing for compatiblity on a test network (or test  
computer for smaller-scale operations) before rolling out an update.

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 18, 2013, 1:03pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/115 "2013-03-18T13:03:59Z")

</div>

“Any support for 1.8.7 (like security fixes) will end this year.”

what do you meant by this line? I don’t understand what you meant by  
support for 1.8.7 will end?

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 18, 2013, 2:29pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/116 "2013-03-18T14:29:59Z")

</div>

hi Joel P.,

You told me to refer the another discussion for popup, I used your code  
here,

$browser.windows.each {|w| w.close rescue nil}  
$browser.close rescue nil

But it is not closing the window as you told there.

My problem is, when i am pressing the next button one pop up is getting  
opening in a new window.I used above code of yours, but it’s not  
working.what should I do to handle that pop up? In the earlier case, pop  
up was attached with browser window, so I used the developer tool to  
find the id and i succeeded but I now I couldn’t use the developer tool  
also.

And also I need to read the message on the pop up, Is it possible ? you  
only have given the way to close the pop up.  
RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 18, 2013, 1:20pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/117 "2013-03-18T13:20:00Z")

</div>

Ok thank you.

RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 18, 2013, 3:18pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/118 "2013-03-18T15:18:33Z")

</div>

hi I have used the below code,

puts $browser.windows.count  
$browser.windows.each do |w|  
puts w.title  
w.close  
end

but it is not closing the pop up. but it’s printing the title and count  
also.I think w.close is not working. what can i do to solve this  
problem?And also the pop consist of Ok button, can i press that OK  
button?

I didn’t understand this message

$browser. (code to read the message here)

what you meant here? how would I write the code to read the pop message?

RAJ

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 18, 2013, 3:41pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/119 "2013-03-18T15:41:47Z")

</div>

When you say “popup” do you mean a Javascript Alert?

If so, in the latest versions of watir-webdriver I believe that’s as  
easy as:  
puts $browser.alert.text  
$browser.alert.close

---

<div class="post-metadata">

**Author:** ![rganapathy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@rganapathy](https://www.ruby-forum.com/u/rganapathy)\
**Post date:** [March 18, 2013, 3:00pm UTC](https://www.ruby-forum.com/t/question-on-watir/224437/120 "2013-03-18T15:00:59Z")

</div>

It helps to get some feedback using IRB:

puts $browser.windows.count

$browser.windows.each {|w| puts w.title }

#The last window should be your popup:  
$browser.windows.last.use do  
$browser. (code to read the message here)  
end

[Previous page](https://www.ruby-forum.com/t/question-on-watir/224437.md?page=5)

[Next page](https://www.ruby-forum.com/t/question-on-watir/224437.md?page=7)
