Snip2Code is shutting down.
It has been quite a ride, since 2013 when we launched our first prototype: thanks to the effort of you guys we collected more than 3 million snippets!
We are very proud to help all our users to be more efficient in their jobs, and to be the central point to share programming knowledge for everyone.
Our basic service is free, so we always survived on our own resources to give you Snip2Code.
Unfortunately, we are no more in the financial position to sustain this effort, and therefore we are announcing here our permanent shut down,
which will take place on August 1st, 2020.
Please save your private snippets using our backup function in the settings, here.
This will allow us to pay for the servers and the infrastructure. If you want to donate, Contact Us!
3 7
Top 1% !

Published on:

No tags for this snippet yet.

cucumber setup with docker chrome standalone

cucumber setup with docker chrome standalone: 
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
require 'selenium/webdriver' ### # Important details: # - Capybara server is run on the host container at # - Test code determines the host's advertised IP address e.g. # - Capybara Instructions execute on selenium/standalone-chrome container via api call to and gives it urls such as to visit the server on the host container. # - This works on an OSX host with manually running the selenium container with docker run -p 4444:4444 selenium/standalone-chrome:3.0.1-germanium # # # Interaction (host ip # - host api call to selenium -> # - selenium browser visit -> # $remote = true $browser = :chrome # $browser = :firefox $wait_time = 5 $default_driver = :selenium # establish capabilities desired_capabilities = begin if $browser == :firefox Selenium::WebDriver::Remote::Capabilities.firefox(loggingPrefs: {browser: 'ALL'}) else # Tell selenium we want all messages by default - we'll sort them out with our own +ConsoleMessages+ class prefs = { # # No change with the following # ---------------------------------- # --js-flags="--max-old-space-size=500" # --disable-backing-store-limit # --diagnostics # --disable-extensions # --enable-leak-detection --crash-on-failure # Not yet tried but might be interesting # --------------------------------------- # --diagnostics # --disable-background-networking # --disable-background-timer-throttling # --disable-backing-store-limit # switches: %w(--disable-notifications --enable-leak-detection --crash-on-failure), loggingPrefs: { browser: 'ALL' #, # performance: 'ALL' }, chromeOptions: { prefs: { credentials_enable_service: false, # disable saved passwords profile: { password_manager_enabled: false # disable saved passwords } } } } end end # For debugging selenium itself: # Selenium::WebDriver.logger.level = :debug if $remote == true # Capybara.register_driver $default_driver do |app| # noinspection RubyArgCount, { browser: :remote, url: '', # selenium hub accessible url desired_capabilities: desired_capabilities }) end else # Register chrome browser for the :selenium driver, can be triggered below with @show Capybara.register_driver $default_driver do |app| # noinspection RubyArgCount, { browser: $browser, desired_capabilities: desired_capabilities }) end end # Make the server available on the network. default is which is private Capybara.server_host = '' Capybara.server_port = 4100 Capybara.server = :puma cuke_log "Capybara running on #{Capybara.server_host}:#{Capybara.server_port} Process: #{}" ENV['CIRCLE_NODE_INDEX'] = '9' unless ENV['CIRCLE_NODE_INDEX'].presence # default the node for local testing # first time around, we need this set. Capybara.default_driver = $default_driver Capybara.default_max_wait_time = $wait_time # # If the @show tag is present on a non-mac environment, ignore it, # otherwise allow the combination of @javascript @show to trigger the # :selenium driver (which is :chrome browser as configured above) # Before do |scenario| @scenario = scenario raise 'Scenario should not have @javascript tag, it really messes up truncation' if has_tag(scenario, '@javascript') # reset the default driver Capybara.current_driver = $default_driver Capybara.javascript_driver = $default_driver Capybara.default_max_wait_time = $wait_time # reset in case a scenario upped it # OLD, but if we need to exec a script to clear storage or cache, do it here. # page.driver.execute_script('window.localStorage.clear()') if should_show(scenario) # for some reason, just using the `using_driver` doesn't get us all the way there, so set/reset the `javascript_driver` as necessary. Capybara.current_driver = :selenium Capybara.javascript_driver = :selenium # needed for @show with chrome, as it doesn't seem to explicitly set the javascript driver end # cuke_log "Using #{Capybara.current_driver}/#{Capybara.javascript_driver}/#{Capybara.default_driver} wait: #{Capybara.default_max_wait_time}" end After do |scenario| # problem on @show with backgrounds: # cuke_log "Done #{Capybara.current_driver}/#{Capybara.javascript_driver}/#{Capybara.default_driver} - resetting driver and sessions." Capybara.use_default_driver Capybara.reset_sessions! end def selenium? Capybara.current_driver == :selenium end
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus