spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

With Rails 4 and selenium web driver, use Sauce Labs on Travis CI but not locally


For those with similar needs, this is what I ended up doing:

.travis.yml:

env:
  global:
    - secure: "encrypted sauce username"
    - secure: "encrypted sauce secret key"

addons:
  sauce_connect: true

before_install:
  # install the ed text editor which we use to
append 
  # file contents to a specific line of another
file
  - sudo apt-get install -y ed
  # appends contents of travis/Gemfile.travis to
Gemfile
  - cat travis/Gemfile.travis >> Gemfile
  # adds contents of travis/rails_helper.rb.travis
to line 12 of spec/rails_helper.rb
  - ed -s spec/rails_helper.rb <<< '12r
travis/rails_helper.rb.travis'$'
w'

travis/Gemfile.travis:

group :test, :development do
  gem 'sauce', '~> 3.1.1'
  gem 'sauce-connect'
  gem 'parallel_tests'
end

travis/rails_helper.rb.travis:

require 'sauce'
require 'sauce/capybara'

# change to "Capybara.default_driver = :sauce" to
use sauce 
# for ALL feature specs, not just ones marked with
"js: true"
Capybara.javascript_driver = :sauce

Sauce.config do |config|
  config[:browsers] = [
    ['Linux', 'Chrome', nil],
    # and other OS/browser combos you want to
support...
  ]
end

UPDATE (2014/11/25):

I ended up using a slightly different configuration in my final solution. I didn't like the brittleness of inserting at a line number. Instead of having special Sauce inclusions in separate files, I just nested special configuration in a conditional, depending on whether an environment variable SAUCY is set to true.

.travis.yml:

env:
  global:
    - secure: "encrypted sauce username"
    - secure: "encrypted sauce secret key"
    - SAUCY: true

addons:
  sauce_connect: true

Gemfile:

group :development, :test do
  # other gems...
  if ENV['SAUCY']
    # gems for sauce
    gem 'sauce', '~> 3.1.1'
    gem 'sauce-connect'
    gem 'parallel_tests'
  end
end

spec/rails_helper.rb:

# after other requires
if ENV['SAUCY']
  require 'sauce'
  require 'sauce/capybara'

  # change to "Capybara.default_driver = :sauce"
to use sauce 
  # for ALL feature specs, not just ones marked
with "js: true"
  Capybara.javascript_driver = :sauce

  Sauce.config do |config|
    config[:browsers] = [
      ['Linux', 'Chrome', nil],
      # and other OS/browser combos you want to
support...
    ]
  end
end

This way, I can also easily use Sauce locally if I choose to with:

SAUCY=true bundle install
SAUCY=true SAUCE_USERNAME=username
SAUCE_ACCESS_KEY=access_key bundle exec rspec

Categories : Ruby On Rails

Related to : With Rails 4 and selenium web driver, use Sauce Labs on Travis CI but not locally
Incorrect URL displayed upon using driver.getCurrentUrl() in Webdriver, Selenium
This shouldn't be happening but anyhow you can use JavascriptExecutor to fetch the current url as: JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("return window.location.href").toString();

Categories : Selenium
Selenium Web driver Not able to find New window triggered after accepting the alert
Using java8 you can use for insted public static String getNewWindow(WebDriver driver) { List<String> newWindow = driver.getWindowHandles().stream() .filter(n -> windows.contains(n) == false).collect(Collectors.toList()); System.out.println(newWindow.get(0)); return newWindow.get(0); }

Categories : Internet Explorer
100% code coverage with different PHP versions in Travis-CI
Using another example I found, I discovered that @requires negatively impacts code coverage. For example: <?php require_once('class.php'); class FooTest extends PHPUnit_Framework_TestCase { /** * @requires PHP 5.5 * @covers Foo::greater */ public function testGreater() { $x = new Foo(); $this->assertSame(2, $x->greater()); } public function

Categories : PHP
XSL works locally but not online
You might have a single space before <?xml version="1.0" encoding="ISO-8859-1"?> In Location: https://dl.dropboxusercontent.com/u/100394705/Games/Minecraft/BMCCraft/BMCCraft.xsl. The errors I'm getting are all related to parsing that file, so try checking for and deleting any non-necessary white-space.

Categories : Xml
Locally "forking" a git repo
Either process should work for what you are looking for. As for whether they are the same thing, they are very similar but copying (cp -r) will result in keeping the current branch setting whereas cloning (git clone) will put you back on the HEAD branch. Cloning will still fetch other branches and you can still use git checkout to switch back on to a branch. This probably won't matter much cons

Categories : GIT
Recently Add
How do I show two different partials on every other pageview?
Ruby on Rails: Populate view based on database column values
Wrapping the bootstrap-sass gem in another gem causes asset manifests to break
.where.not with empty array
assign_attributes and save later in loop - ruby rails
File from a Delayed Job to Uploader
mongoid validate uniqueness of each member in has_many or has_and_belongs_to_many relation
Gibbon Mailchimp integration simply not working
No terminal output with caypbara / rspec / selenium-webdriver
Rack::ShowExceptions enabled in production Rails 4.0.4
Ruby on Rails access whole params hash
Can I view Rails documentation with pry?
Why isn't the confirm box working?
Polymorphic models (not associations!) in Rails
Link_to :Action won't call Controller Method -- Rails 4
Missing template when rendering a collection using local variables
rails simple_form using virtual attributes
uninitialized constant ActiveSupport::TestCase
Rails 4, Paperclip, S3 wrong url path
Neo4j gem - Updating relationship properties method
Error trying to deploy Rails app to Heroku
Modyfying before_action
CarrierWave TypeError (can't dump File) on Heroku
CanCan Ability in Rails - Giving partial manage
Uploading two images using s3 and paperclip on rails app
How to pass hash values of ActiveRecord::Base class
Ruby on rails. Heroku compile assets timeout when i add unicorn gem
Rails Template is Missing Error
Time.now.to_i different on heroku and locally
Simple rails app on Puma throws segfault, cannot handle concurrency
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.