Skip to content

Instantly share code, notes, and snippets.

@DylanLacey
Last active March 21, 2017 06:52
Show Gist options
  • Save DylanLacey/ef88533906652815e2ae0a1260b320cd to your computer and use it in GitHub Desktop.
Save DylanLacey/ef88533906652815e2ae0a1260b320cd to your computer and use it in GitHub Desktop.
Demonstrate limited storage on Sauce Labs machines

Preconditions

  1. Sane Ruby environment
  2. Bundler installed
  3. SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variable set

Set Up

  1. Download Gemfile and repro.rb into replication directory and cd to same
  2. Run bundle install

Running test

  1. bundle exec ruby repro.rb
  2. You will see the available and quota storage displayed for each platform
source "https://www.rubygems.org"
gem "selenium-webdriver"
gem "net-http-persistent"
#blank selenium test
require "selenium-webdriver"
def un
ENV["SAUCE_USERNAME"]
end
def pw
ENV["SAUCE_ACCESS_KEY"]
end
def auth
"#{un}:#{pw}"
end
def server
"ondemand.saucelabs.com"
end
def port
80
end
def endpoint
"http://#{auth}@#{server}:#{port}/wd/hub"
end
def caps_array
[
{browserName: 'chrome', version: '56', platform: "windows 7"},
{browserName: 'chrome', version: '56', platform: "windows 10"},
{browserName: 'chrome', version: '56', platform: "OS X 10.12"},
]
end
caps_array.each do |caps|
driver = Selenium::WebDriver.for :remote, :url => endpoint, :desired_capabilities => caps
driver.navigate.to "http://www.bees.com"
driver.execute_script "navigator.webkitTemporaryStorage.queryUsageAndQuota(function(usage, quota){ window.used = usage; window.quota = quota; });"
used = driver.execute_script "return window.used"
quota = driver.execute_script "return window.quota"
used = used / 1048576 if used > 0
quota = quota / 1048576 if quota > 0
puts "#{caps[:browserName]} #{caps[:version]} on #{caps[:platform]} - #{used}Mb used out of #{quota}Mb quota"
driver.quit
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment