也许这只是一个实际问题,但似乎在我“click_link”与目标=“空白”挂钩时,本届会议将重点放在目前的窗口上。
因此,我要么希望能够转向新的窗口,要么忽视“空白属性”——基本上,我只希望它实际上走到该链接所显示的网页上,以便我能够确保该链接的正确网页。
我使用网基和 se司机。
页: 1 回答更为彻底。
此外,这只是ium——对网基驱动力(或指出我可以发现自己之处)的等同——的工作将受到高度赞赏。
也许这只是一个实际问题,但似乎在我“click_link”与目标=“空白”挂钩时,本届会议将重点放在目前的窗口上。
因此,我要么希望能够转向新的窗口,要么忽视“空白属性”——基本上,我只希望它实际上走到该链接所显示的网页上,以便我能够确保该链接的正确网页。
我使用网基和 se司机。
页: 1 回答更为彻底。
此外,这只是ium——对网基驱动力(或指出我可以发现自己之处)的等同——的工作将受到高度赞赏。
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
这一解决办法只针对 Sel升司机。
所有露天窗都是 Sel的商店
response.driver.browser.window_handles
这似乎是一个阵容。 最后一个项目始终是最近打开的窗口,这意味着你可以做以下工作来转用。
在一栏内:
new_window=page.driver.browser.window_handles.last
page.within_window new_window do
#code
end
简单地重议本届会议:
session.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
http://github.com/jnicklas/capybara/issues/173。
http://qastuffs.blogspot.com/2010/10/testing-pop-up-windows-using-selenium.html
现在,,与Potergeist合作。 虽然window_handles
仍然没有得到执行(青年需要一个窗口的名称,即通过 Java成像):
within_window other_window do
current_url.should match /example.com/
end
<><>Edit>: 下面的评述是,Potergeist现在实施window_handles
,自。
Capybara提供了一些方法,以方便发现和转换窗口:
facebook_window = window_opened_by do
click_button Like
end
within_window facebook_window do
find( #login_email ).set( a@example.com )
find( #login_password ).set( qwerty )
click_button Submit
end
More details here: Capybara documentation
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
Seems such as it is not possible withcapybara-webkit now: https://github.com/thoughtbot/capybara-webkit/issues/271
:
与此同时,s http://gith.com/ th/ 申 诉是有可能的。
http://github.com/thoughtbot/capybara-webkit/issues/47“https://github.com/thoughtbot/capybara-webkit/issues/47 建议page.driver.browser.switch_to().window(page.driver.browser.window_handles.last)
工作。 Ah, 待读。
http://github.com/thoughtbot/capybara-webkit/pull/314。 http://github.com/mhoran/capybara-webkit-demo>。
As of May 2014 the following code works on capybara-webkit
within_window(page.driver.browser.window_handles.last) do
expect(current_url).to eq( http://www.example.com/ )
end
为明确改变窗户,您使用switch_to_window >>/strong>
def terms_of_use
terms_window = window_opened_by do
click_link(@terms_link)
end
switch_to_window(terms_window)
end
这种方法之后,浏览器将在新网页上工作,而不是在<<<>,in_window<<<>>>><<>>>>>><<>>>>>>>>>>>。 路障
这对我来说是靠 cap巴网做的:
within_window(windows.last) do
# code here
end
(一米,使用帽子2.4.1和帽子13.0)
You can pass a name, url or title of the window also (But now its dipricated)
let(:product) { create :product }
it tests do
visit products_path
click_link(product.id)
within_window(product_path(product)) do
expect(page).to have_content(product.title)
end
end
页: 1 并且
within_window(->{ page.title == Page title }) do
click_button Submit
end
希望它把方法的使用延伸到更为明显的障碍
I had this issue when opening links in an gmail window: I fixed it like this:
Given /^(?:|I )click the "([^"]*)" link in email message$/ do |field|
# var alllinks = document.getElementsByTagName("a");
# for (alllinksi=0; alllinksi<alllinks.length; alllinksi++) {
# alllinks[alllinksi].removeAttribute("target");
# }
page.execute_script( var alllinks = document.getElementsByTagName("a"); for (alllinksi=0; alllinksi<alllinks.length; alllinksi++) { alllinks[alllinksi].removeAttribute("target"); } )
within(:css, "div.msg") do
click_link link_text
end
end
The best idea is to update capybara to the latests version (2.4.1) and just use
windows.last
because page.driver.browser.window_handles
is deprecated.
主要实施(window_ opened_by
)给我带来了错误:
*** Capybara::WindowError Exception: block passed to #window_opened_by opened 0 windows instead of 1
因此,我通过这一解决办法解决这个问题:
new_window = open_new_window
within_window new_window do
visit(click_link Something )
end
page.driver.browser.window_handles
# => ["CDwindow-F7EF6D3C12B68D6B6A3DFC69C2790718", "CDwindow-9A026DEC65C3C031AF7D2BA12F28ADC7"]
I personally like the following approach since it works correctly regardless of JS being enabled or not.
My Spec:
it "shows as expected" do
visit my_path
# ...test my non-JS stuff in the current tab
switch_to_new_tab
# ...test my non-JS stuff in the new tab
# ...keep switching to new tabs as much as necessary
end
# OR
it "shows as expected", js: true do
visit my_path
# ...test my non-JS stuff in the current tab
# ...also test my JS stuff in the current tab
switch_to_new_tab
# ...test my non-JS stuff in the new tab
# ...also test my JS stuff in the new tab
# ...keep switching to new tabs as much as necessary
end
测试助手:
def switch_to_new_tab
current_browser = page.driver.browser
if js_enabled?
current_browser.switch_to.window(current_browser.window_handles.last)
else
visit current_browser.last_request.fullpath
end
end
def js_enabled?
Capybara.current_driver == Capybara.javascript_driver
end
Are there database testing tools for python (like sqlunit)? I want to test the DAL that is built using sqlalchemy
I have been tasked with looking for a performance testing solution for one of our Java applications running on a Weblogic server. The requirement is to record production requests (both GET and POST ...
I am using selenium-server , selenium rc for UI testing in my application . My dev box is Windows with FireFox 3.5 and every thing is running fine and cool. But when i try to run selenium tests on my ...
I have an iPhone web app I m producing on a Linux machine. What s the best browser I can use to most closely mimic the feature-limited version of Safari present on the iPhone? (It s a "slimmed down" ...
Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...
I am testing in selenium and I have a bunch of stuff that happens on page load. I found out about autoit, and I was thinking that it could handle all javascript dialog issues. I was searching around ...
I use cucumber to run integration tests. I have a very large (30,000+ record) stardard setup for testing. How can I leave that in the test.sqlite3 database without re-loading it ever?
Wondering if there was some sort of crawler we could use to test and re-test everything when changes are made to the web app so we know some new change didn t error out any existing pages. Or maybe a ...