问题描述
也许这实际上并不是我遇到的问题,但是似乎当我点击链接到target = _ blank的链接时,会话会将焦点集中在当前窗口上。
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 window.
所以我要么希望能够切换到新窗口,要么就忽略_blank属性-本质上,我只希望它实际转到链接所指示的页面,以便我可以确保它是正确的页面。
So I either want to be able to switch to the new window, or to ignore the _blank attribute - essentially, I just want it to actually go to the page indicated by the link so I can make sure it's the right page.
我使用webkit和硒驱动程序。
I use the webkit and selenium drivers.
我到目前为止已经提交了我的发现。
I submitted my findings thus far below. A more thorough answer is much appreciated.
此外,这仅适用于硒-与webkit驱动程序等效(或指出我可以在哪里发现它)
Also, this only works with selenium - the equivalent for the webkit driver (or pointing out where I could discover it myself) would be much appreciated.
推荐答案
Capybara> = 2.3包括新的窗口管理API。可以这样使用:
Capybara >= 2.3 includes the new window management API. It can be used like:
new_window = window_opened_by { click_link 'Something' }
within_window new_window do
# code
end
这篇关于使用Capybara,如何切换到新窗口以显示带有“ _blank”链接的链接。目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!