Useful Cucumber steps for other Capybara/Selenium tests
[2011-02-03]To verify the content of a new page, opened with target blank:
Then /^I should see "([^\"]*)" within a new window$/ do |text| within_window(page.driver.browser.window_handles.last) do if defined?(RSpec::Matchers) page.should have_content(text) else assert page.has_content?(text) end end end
To verify the content of a popup:
Then /^I should see "([^\"]*)" within popup "([^\"]*)"$/ do |text, popup_handle|
within_window(popup_handle) do
if defined?(RSpec::Matchers)
page.should have_content(text)
else
assert page.has_content?(text)
end
end
end
To fill a CK editor with Capybara and Selenium:
When /^I fill the CKeditor enhanced "([^\"]*)" with "([^\"]*)"$/ do |name, value|
js = "CKEDITOR.instances.#{name}.setData('#{value}');"
page.execute_script(js)
end
To fill an FCK editor with Capybara and Selenium:
When /^I fill in the FCK enhanced "([^\"]*)" with "([^\"]*)"$/ do |input_id, value|
if Capybara::Driver::Selenium === page.driver
browser = page.driver.browser
browser.switch_to.frame("#{input_id}___Frame")
browser.switch_to.frame(0)
editor = page.find(:css, 'body').native
editor.send_keys(value)
browser.switch_to.default_content
end
end
To confirm a JS confirm dialog box with Capybara and Selenium:
When /^I confirm a js popup on the next step$/ do
evaluate_script("window['confirm'] = function() { return true; }")
end
-> more
itmewewhy.com
[2010-07-26]Recently I launched itmewewhy.com, a book site for the book "the principles of physical complexity" by Jos Koomen. Feel free to check it out.
-> more
SSH problem
[2010-05-07]Hmm, was getting an error when I tried to log in a remote server using an id-rsa key I generated.
Agent admitted failure to sign using the key. Permission denied (publickey).
but after I did an
ssh-add
I got it working... ;-)
-> more
What to do after an x11-base/xorg-server update?
[2010-04-19]Did an emerge world on my gentoo system, and one of the packages that got updated was x11-base/xorg-server. That broke my system.
And here's how to fix it:
emerge -1av $(eix --only-names -I xf86- -C x11-drivers)
Even better:
emerge -1av $(qlist -I -C x11-drivers/)
-> more
Networking disabled after a suspend on Gentoo
[2010-04-09]My lovely little laptop running Gentoo was suspended by me. It uses very little battery when suspended, but while I forgot to resume and didn't use it for a few days it shut down completely.
Sounds fine, but when booting up again my networking was disabled. The networkmanager applet just displays "Networking disabled".
This was causes by this line
NetworkingEnabled=false
in this file
/var/lib/NetworkManager/NetworkManager.state Changing false to true did the trick!
-> more
Drawblog update
[2010-02-23]Added an awful lot of my new drawings to my drawblog past few days!
-> more
What I hate most on the internet these days
[2010-02-18]Is noise. Video's that start to play when you open a page. When surfing, reading my email or RSS feeds, I open lot's of pages all in new Firefox tabs. A nice and quiet morning, listening to some subtle music, all off a sudden I hear an awfull lot of noise.
Apparently 2 of these tabs have video's on them, so I now hear 2 video's at the same time. In 2 of those 25 tabs that are open. Have to browse through all of these tabs to find out which are the one's, and close them immediately.
I don't like people shouting in my ears.
But I'm woken up now.
-> more