Watir webdriver; window.close正在关闭整个浏览器?

时间:2016-10-13 20:43:51

标签: rspec tabs watir-webdriver

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

# 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

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

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作为我的最后一个代码,那么它是否正常工作?有关导致此问题的任何想法?

1 个答案:

答案 0 :(得分:1)

Mozilla不会也不会支持与Firefox中的标签进行交互。 https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/3380