How to open the new tab in chrome using ruby watir in rubymine

1,083 views
Skip to first unread message

duggimpudi

unread,
Dec 12, 2016, 4:52:15 PM12/12/16
to Watir General
I need to open the tab parallely when am executing my scenario in same browser in chrome. Am using rubymine with ruby for executing my steps.

eg:Let say my scenario has 10 steps after completion of the 7th step(cucmber) i need to open the same url in another tab before that execution tab close. Thanks in advance for your response.


Titus Fortner

unread,
Dec 12, 2016, 5:55:56 PM12/12/16
to watir-general

To open a new window:
browser.execute_script('window.open("http://google.com")')



On Mon, Dec 12, 2016 at 3:46 PM, duggimpudi <duggimpu...@gmail.com> wrote:
I need to open the tab parallely when am executing my scenario in same browser in chrome. Am using rubymine with ruby for executing my steps.

eg:Let say my scenario has 10 steps after completion of the 7th step(cucmber) i need to open the same url in another tab before that execution tab close. Thanks in advance for your response.


--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.
 
watir-...@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raja gopalan

unread,
Dec 13, 2016, 9:12:40 AM12/13/16
to Watir General
It's opening new window but it's loading wrong url in the second window, for an example, I have written the following code

require 'watir'
b=Watir::Browser.new :chrome
b.goto 'www.google.com'
b.execute_script('window.open("www.yahoo.com")')

gets

but it's loading the given below url, 

https://www.google.co.in/www.yahoo.com 

What's the problem here?  

On Tuesday, December 13, 2016 at 4:25:56 AM UTC+5:30, Titus Fortner wrote:

To open a new window:
browser.execute_script('window.open("http://google.com")')


On Mon, Dec 12, 2016 at 3:46 PM, duggimpudi <duggimpu...@gmail.com> wrote:
I need to open the tab parallely when am executing my scenario in same browser in chrome. Am using rubymine with ruby for executing my steps.

eg:Let say my scenario has 10 steps after completion of the 7th step(cucmber) i need to open the same url in another tab before that execution tab close. Thanks in advance for your response.


--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.
 
watir-...@googlegroups.com
http://groups.google.com/group/watir-general


---
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-genera...@googlegroups.com.

Lucas Tierney

unread,
Dec 13, 2016, 10:17:25 AM12/13/16
to Watir General
You need to have 'http://' in front of 'www.yahoo.com' (look at how Titus did it)

Raja gopalan

unread,
Dec 14, 2016, 1:03:44 AM12/14/16
to Watir General
Lucas,

Thank you, it works fine.
Reply all
Reply to author
Forward
0 new messages