More Related Content
Similar to Selenium with pixiv
Similar to Selenium with pixiv (8)
Selenium with pixiv
- 12. Seleniumのコード
ちょっと使いづらい
#! /bin/env ruby
require "selenium-webdriver"
#Firefox browser instantiation
driver = Selenium::WebDriver.for :firefox
#Loading the assertselenium URL
driver.navigate.to "http://www.example.com"
#Clicking on the Follow link present on the assertselenium home
FollowButton = driver.find_element(:link, "Follow")
FollowButton.click
#Asserting whether the registration success message is diaplyed
SuccessMessage = driver.find_element(:css, "p.message")
#Quitting the browser
driver.quit
- 14. Capybaraのコード(イメージ)
#! /bin/env ruby
require "capybara"
require "selenium-webdriver"
visit "https://www.pixiv.net"
find("a.signup-form__submit--login").click
within "#container-login form .input-field-group" do
find("input[type="text"]").set(user)
find("input[type="password"]").set(password)
end
submit = find("form button.signup-form__submit")
submit.click
いい感じ
- 23. Capybara.register_driver :selenium do |app|
caps = Selenium::WebDriver::Remote::Capabilities.new
caps['browser'] = ENV.fetch('SELENIUM_BROWSER', 'IE')
caps['browser_version'] = ENV.fetch('SELENIUM_BROWSER_VERSION'
caps['os'] = ENV.fetch('SELENIUM_OS', 'Windows')
caps['os_version'] = ENV.fetch('SELENIUM_OS_VERSION', '8.1'
caps['resolution'] = ENV.fetch('SELENIUM_RESOLUTION', '1024x76
caps['browserstack.local'] = false
caps['browserstack.video'] = true
caps['browserstack.debug'] = true
caps['browserstack.networkLogs'] = true
caps['build'] = ENV['BUILD_NUMBER']
client = Selenium::WebDriver::Remote::Http::Default.new
username = ENV['BROWSERSTACK_USER']
authkey = ENV['BROWSERSTACK_PASSWORD']
url = "http://#{username}:#{authkey}@hub.browserstack.com:80/w
Capybara::Selenium::Driver.new(
app,
:browser => :remote,
:url => url,
:desired_capabilities => caps