Question

I use Radrails for watir tests. Here is my code:

ie.link(:text, "First").click
ie.link(:text, "Second").click
ie1 = Watir::IE.attach(:title, "Second")

Next I watch the test execution. I see ie windows. After clicking a second window opens in a new browser window in a new tab. Now I want to operate in this new tab, but in IE is displaying the first tab. I want see how commands are executed in the new tab which is called Second. Could someone suggest how to do this?

Was it helpful?

Solution

To my knowledge, Watir does not have any direct support for working with browser tabs.

However, given that you just want to view the tab, you can use IE's keyboard shortcuts for working with tabs (http://windows.microsoft.com/en-us/windows7/internet-explorer-keyboard-shortcuts).

Assuming that the tab opened is the last one, you can switch to it using:

ie.send_keys([:control, '9'])

Or if it is the next tab, you can switch to it using:

ie.send_keys([:control, :tab])
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top