Skip to content

Instantly share code, notes, and snippets.

@rafaelbiriba
Last active May 27, 2020 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelbiriba/98da2eef41856081707391941976ee23 to your computer and use it in GitHub Desktop.
Save rafaelbiriba/98da2eef41856081707391941976ee23 to your computer and use it in GitHub Desktop.
selenium ruby playground
require 'rubygems'
require 'bundler/setup'
require "selenium-webdriver"
require "faker"
def generate_email
domains = ["example.com", "example2.com"]
Faker::Internet.unique.email(domain: domains.sample, separators: ".")
end
profile = Selenium::WebDriver::Firefox::Profile.new
proxy = Selenium::WebDriver::Proxy.new(:http => nil)
profile.proxy = proxy
driver = Selenium::WebDriver.for :firefox, :profile => profile
wait = Selenium::WebDriver::Wait.new(:timeout => 15)
100_000.times do |i|
puts "#{i} from 100.000" if i % 500 == 0
driver.navigate.to "https://example.com"
element = wait.until { driver.find_element(:xpath, "//button[contains(text(),'start')]") }
element.click
element = wait.until { driver.find_element(:id, "email") }
element.send_keys generate_email
sleep rand(10)
element = wait.until { driver.find_element(:id, "submit") }
element.click
end
driver.quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment