How to attach a new tab?

99 views
Skip to first unread message

wesley chen

unread,
Aug 26, 2008, 3:54:17 AM8/26/08
to Watir General
Suppose I have turned to www.google.com in IE7.
ie1=Watir::IE.start("www.google.com")
I would like to attach a new tab in the window, in the new tab, I would like to go to www.yahoo.com
How can I achieve it?

There is a method
Watir::IE.attach(:title, /title/)
What does the 'title' mean? the existent tab name?

Any suggestion would appreciated.


--:)
Man should be hard to himself, but tolerant to others.

wesley chen

unread,
Aug 26, 2008, 6:26:24 AM8/26/08
to Watir General
Now, I can locate any tab I want, but I still don't know how to create a new tab.
require 'watir'
s=[]
t=[]
Watir::IE.each do |x|
    s << x.title
    t << x.url
end

#puts the tab title and the cooperating url
puts s
puts t

#Practice on the cooperating tab.
ie2=Watir::IE.attach(:title, /Google Search/i)
ie2.goto("www.yahoo.com")


--:)
Man should be hard to himself, but tolerant to others.


Željko Filipin

unread,
Aug 26, 2008, 6:29:05 AM8/26/08
to watir-...@googlegroups.com
On Tue, Aug 26, 2008 at 12:26 PM, wesley chen <cjq...@gmail.com> wrote:
>I still don't know how to create a new tab.

Set browser to open links in new tab instead of new window, if that is what you need.

Željko
--
wakoopa.com/ZeljkoFilipin

wesley chen

unread,
Aug 26, 2008, 6:55:36 AM8/26/08
to watir-...@googlegroups.com
Hi, Zeljko,
I can create a blank tab manual and go to the page using watir:
require 'watir'
ie2=Watir::IE.attach(:title, '')
#ie2=Watir::IE.attach(:url, 'about:blank')
ie2.goto("www.google.com")

But how can I create a blank tab using watir automatic in an existent IE window?

wesley chen

unread,
Aug 26, 2008, 7:05:27 AM8/26/08
to watir-...@googlegroups.com
Hi, Zeljko,
Maybe we can send Ctrl + T to create the new tab.
But I don't know how to use it, I know there are may keyboard practice commands in Watir, I have never succeed to try the commands, I don't know why, will you please write the code down? Maybe I can follow you and then, I will learn how to use send_keys or send function.

Thanks very much.
Any other suggestion would be also OK if we don't use Ctrl +T. I kind of find that, in watir, the Send or send_keys commands are not so sensitive and exactly to practice. Maybe I have lost something.

Yours.
Wesley Chen.

Željko Filipin

unread,
Aug 26, 2008, 7:07:40 AM8/26/08
to watir-...@googlegroups.com
On Tue, Aug 26, 2008 at 1:05 PM, wesley chen <cjq...@gmail.com> wrote:
> Maybe we can send Ctrl + T to create the new tab.

I think people use autoit for such things.
http://www.autoitscript.com/autoit3/

I never had to use it, so I really do not know how it works.

Željko
--
twitter.com/WatirPodcast

wesley chen

unread,
Aug 26, 2008, 7:10:04 AM8/26/08
to watir-...@googlegroups.com
:), thank you all the same.


--:)
Man should be hard to himself, but tolerant to others.


Reply all
Reply to author
Forward
0 new messages