Use different user agents per cucumber scenario
So I needed to test a redirect that only happened for IOS devices. I had no idea how to accomplish this with a specific cucumber scenario. So I did what any good developer would do. I figured it out.
Here is how:
make a new file features/support/custom_user_agents.rb
Capybara.register_driver :iphone do |app| require 'selenium/webdriver' profile = Selenium::WebDriver::Firefox::Profile.new #Change the line below to change the user agent profile['general.useragent.override'] = "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A535b Safari/419.3" Capybara::Selenium::Driver.new(app, :profile => profile) end Capybara.use_default_driver
then tag your scenario with @iphone and it will automatically use the new selenium driver we just created! Other scenarios will still use the default driver. Hope this helps save someone some time.
- Linkdump of Awesome Stuff #24
- The Bitcraze Crazyflie is the best quadcopter ever
- Update v1.0.1: Quickly get a fresh ubuntu install ready for ruby dev
- Build your own web framework with Rack and Ruby - Part 1
- Linkdump of Awesome Stuff #23
- Quickly get a fresh ubuntu install ready for ruby dev
- It's a bird! It's a plane? No! It's Meteor coming to destroy your old ways.
- Linkdump of Awesome Stuff #22
- Fix your Python 2.7.4 MAXREPEAT ImportError issues
- Make a snappable cart directive with AngularJS