Skip to content

Instantly share code, notes, and snippets.

@jamesr2323
Created December 3, 2018 23:40
Show Gist options
  • Save jamesr2323/c896e22f5511e4162ae789d085e58264 to your computer and use it in GitHub Desktop.
Save jamesr2323/c896e22f5511e4162ae789d085e58264 to your computer and use it in GitHub Desktop.
require 'selenium-webdriver'
require 'json'
require 'csv'
require 'active_support/all'
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless') # Remove this to watch the browser in testing
options.add_argument(%Q{--user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"})
options.add_argument("--blink-settings=imagesEnabled=false")
driver = Selenium::WebDriver.for(:chrome, options: options)
driver.get("https://www.example.com")
10.times do
driver.execute_script("window.scrollBy(0,2000)")
sleep 2
end
# Do something to load data from page here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment