Last active
August 29, 2015 13:56
-
-
Save artemave/8794022 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'capybara' | |
gem 'poltergeist' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'capybara/dsl' | |
require 'capybara/poltergeist' | |
Capybara.register_driver :poltergeist do |app| | |
Capybara::Poltergeist::Driver.new(app, timeout: 120) | |
end | |
Capybara.default_driver = :poltergeist | |
def geist url | |
if rand(3) == 0 | |
url = url | |
puts Time.now, url | |
Capybara.visit url | |
end | |
sleep rand(5) + 5 | |
rescue Capybara::Poltergeist::JavascriptError => e | |
puts e.message | |
end | |
keywords = %w[stuff books bus joy toy dress shoes apple] | |
Capybara.visit "https://artem-shopa-staging.herokuapp.com/accounts/sign_in" | |
Capybara.fill_in "Email", with: 'artemave@gmail.com' | |
Capybara.fill_in "Password", with: 'password' | |
Capybara.click_button 'Submit' | |
while true do | |
# geist "https://artem-shopa-staging.herokuapp.com/products?keywords=#{keywords.sample}" | |
# geist "https://artem-shopa-staging.herokuapp.com/myshopa/interests/remove" | |
# geist "https://artem-shopa-staging.herokuapp.com/myshopa/interests" | |
# geist "https://artem-shopa-staging.herokuapp.com/myshopa/click_score" | |
geist "https://artem-shopa-staging.herokuapp.com/products/L37537L10511011-a-game-of-thrones" | |
geist "https://artem-shopa-staging.herokuapp.com/products/L38199L855967502-musashi" | |
geist "https://artem-shopa-staging.herokuapp.com/products/L38199L851628006-forbidden-planet-entertainment-store-exclusive-bluray-steelbook" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment