With Capybara, how do I switch to the new window for links with “_blank” targets?

后端 未结 15 2048
花落未央
花落未央 2020-12-02 09:54

Perhaps this isn\'t actually the issue I\'m experiencing, but it seems that when I \"click_link\" a link with target=\"_blank\", the session keeps the focus on the current w

15条回答
  •  情书的邮戳
    2020-12-02 10:11

    I know this is old post, but for what its worth in capybara 2.4.4

    within_window(switch_to_window(windows.last)) do 
        # in my case assert redirected url from a prior click action
        expect(current_url).to eq(redirect['url'])
    end
    

提交回复
热议问题