Oh, this is a Firefox thing:
https://code.google.com/p/selenium/issues/detail?id=3380

You have to open it in a new window:
agent.driver.action.context_click(link.wd).send_keys(:
arrow_down).send_keys(:arrow_down).send_keys(:return).perform



On Thu, Jan 22, 2015 at 1:19 PM, Greg Allen <[email protected]>
wrote:

> That's a good thought, but it still doesn't work.  I even updated the
> timeout to 60 seconds:
>
> $ ruby test.rb
> c:/Progra~2/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.10/lib/watir-webdriver/wait.rb:48:in
> `until': timed out after 60 seconds, waiting for {:index=>1} to become
> present
>  (Watir::Wait::TimeoutError)
>         from
> c:/Progra~2/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.10/lib/watir-webdriver/wait.rb:120:in
> `method_missing'
>         from test.rb:22:in `<main>'
>
>
>
> On Thursday, January 22, 2015 at 2:05:53 PM UTC-5, Titus Fortner wrote:
>>
>> I suspect it is a timing issue, since it is taking the 2nd window a while
>> to load, and watir won't recognize it until it is done.
>> Try:
>> agent.window(index: 1).when_present.use
>>
>>
>>
>> On Thu, Jan 22, 2015 at 11:36 AM, Greg Allen <[email protected]>
>> wrote:
>>
>>> I am using the following code to right-click on a link and open the
>>> target in a new tab in FireFox.
>>>
>>> profile = Selenium::WebDriver::Firefox::Profile.new
>>> profile.native_events = false
>>>
>>> caps = Selenium::WebDriver::Remote::Capabilities.firefox(:native_events
>>> => false)
>>> driver = Selenium::WebDriver.for(:firefox, profile: profile,
>>> desired_capabilities: caps)
>>> agent = Watir::Browser.new(driver)
>>> agent.goto 'http://www.google.com'
>>>
>>> link = agent.a(:class => 'gb_ib')
>>> agent.driver.action.context_click(link.wd).send_keys(:
>>> arrow_down).send_keys(:return).perform
>>> puts agent.windows.count
>>> puts agent.windows.last.title
>>> agent.windows.last.use
>>>
>>> It works fine, except that Watir does not seem to recognize the newly
>>> opened tab. The new tab gets opened, and I would expect the
>>> "agent.window.last.use" command to change the focus to that new tab.
>>> However, it does not.
>>>
>>> In fact, printing out the number of windows results in 1 and the title
>>> of that page is "Google".
>>>
>>> How can I make Watir recognize that I have opened a new tab in this
>>> manner?
>>>
>>> Thanks!
>>>
>>>  --
>>> --
>>> Before posting, please read http://watir.com/support. In short: search
>>> before you ask, be nice.
>>>
>>> [email protected]
>>> http://groups.google.com/group/watir-general
>>> [email protected]
>>>
>>> ---
>>> 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 [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> --
> Before posting, please read http://watir.com/support. In short: search
> before you ask, be nice.
>
> [email protected]
> http://groups.google.com/group/watir-general
> [email protected]
>
> ---
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to