> Ruby on Rails Strategy - From Idea to Mobile App RealityVinova Our team will brainstorm with you on where to begin, where to go, and how to get you there. Whether you have a spark of an idea or an existing app – we can help. Getting your mobile strategy right is what our unique services are all about. We’ll wrestle with business challenges, discover new opportunities that will help you define and refine your product ideas into mobile app reality.

Testing for javascript alerts with Cucumber & Capybara

Using Cumcumber + Capybara to run automated testing is a TRENDY now. But you might have trouble finding a way to assert a javascript alert, for e.g. a link created by the link_to … :confirm => “Are you sure?” and similar.

Don’t worry, here is a work around to confirm Javascript alert and dialog in your Capybara tests, simply override alert and confirm methods:

Given /^I will confirm on next step$/ do
begin
evaluate_script(“window.alert = function(msg) { return true; }”)
evaluate_script(“window.confirm = function(msg) { return true; }”)
rescue Capybara::NotSupportedByDriverError
end
end

Rescue here is added in case, you run want to run your tests without javascript (e.g. default capybara driver). If you run feature without javascript simply nothing will happen.

Moreover, using this technique you can simulate moving mouse over some elements. It is useful, when you have links that appears when certain div is under the mouse cursor.

Then /^I move mouse over “([^”]*)”$/ do |label|
begin
Capybara.current_session.driver.browser.execute_script(“$(‘#{label}’).mouseover();”)
rescue Capybara::NotSupportedByDriverError
end
end

That’s it. Happy testing !

Malcare WordPress Security

singapore mobile app developer,mobile app development singapore,developer in singapore,web design singapore,mobile apps development singapore,mobile game developer singapore,singapore web design,graphic designer in singapore,web development singapore,design agency singapore,website designer singapore,website developer singapore,web design services singapore,singapore website design,web application singapore,ios app development singapore,singapore web development,web designer singapore,singapore mobile application developer,mobile app developer singapore,website design singapore,web development company singapore,mobile application development singapore,mobile developer singapore,app development singapore,ruby on rails developer singapore,developers in singapore,singapore web design services,android developer singapore,mobile apps singapore,web design company singapore,mobile application developer singapore,singapore app developer,app developer singapore,ios developer singapore,website development singapore,design firms in singapore