Watir 网络驱动程序;window.close 正在关闭整个浏览器? [英] Watir webdriver; window.close is closing entire browser?

查看:50
本文介绍了Watir 网络驱动程序;window.close 正在关闭整个浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个测试,我将链接复制/粘贴到新标签.完成后,我希望关闭它,然后继续运行规范中的其他测试.目前的问题是,当我使用 window.close 时,它会关闭整个浏览器实例,而不仅仅是那个特定的窗口.
这是我的通用代码:

I am running a test where I copy/paste a link into a new tab. Once I am finished with it, I am looking to close it, then continue running other tests within the spec. The issue at the moment is that when I use window.close, it is closing the entire browser instance, not just that particular window.
Here is my general code:

# Method for the window
def this_window
    page = @browser.window(:title, 'Foobar')
    return page
end

# Helper method for copy/paste in new tab
def copy_paste_in_new_tab
    @browser.send_keys [:command, 't']
    @browser.send_keys [:command, 'v']
    @browser.send_keys [:return]
end

# How it appears in the spec
it 'goes to new page' do
    copy_paste_in_new_tab
    sleep 1
    this_window.use
end
it 'interacts with new window' do
    # runs some tests on new window correctly
end
it 'closes the window' do
    this_window.close
    sleep 2
end
it 'continues to other tests' do
    # by this point the entire session has closed
end

这是我在终端中遇到的错误:

This is the error I am getting in the terminal:

An error occurred in an `after(:context)` hook.
Errno::ECONNREFUSED: Connection refused - connect(2) for "127.0.0.1" port 7055
occurred at /Users/foo/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:879:in `initialize'

我只在关闭最后一个窗口后尝试执行代码时遇到问题.如果我使用 this_window.close 作为我的最后一个代码,那么它可以正常工作
关于是什么导致这种情况的任何想法?

I am only encountering issues when I try to execute code after closing that last window. If I use this_window.close as my last code, then it works correctly
Any ideas on what is causing this?

推荐答案

Mozilla 不支持也不会支持与 Firefox 中的选项卡交互.https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/3380

Mozilla does not and will not support interacting with tabs in Firefox. https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/3380

这篇关于Watir 网络驱动程序;window.close 正在关闭整个浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆