LoginSignup
2
0

More than 5 years have passed since last update.

Selenium でリンクをたどる (Ruby)

Last updated at Posted at 2018-09-18

Selenium でリンクをたどるサンプルです。

follow_link.rb
#! /usr/bin/ruby
# -*- coding: utf-8 -*-
#
#   follow_link.rb
#
#                   Sep/18/2018
#
# ------------------------------------------------------------------
require 'selenium-webdriver'
# ------------------------------------------------------------------
STDERR.puts "*** 開始 ***"
URL = 'https://ekzemplaro.org'

driver = Selenium::WebDriver.for :firefox
driver.get(URL)

STDERR.puts "*** sleep start ***"
sleep(10)
STDERR.puts "*** sleep end ***"

tag = driver.find_element(:id, 'ekzemplaro')
tag.click()
#
STDERR.puts "*** sleep start ***"
sleep(10)
STDERR.puts "*** sleep end ***"
#
tag = driver.find_element(:link, 'English')
tag.click()
#
STDERR.puts "*** 終了 ***"
# ------------------------------------------------------------------

実行方法

./follow_link.rb
2
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0