I made a tool to automate the work of just popping in order to take the class on a first-come, first-served basis when someone removes it in the lottery course of the university registration. I think that the method of registering for courses differs depending on the university, so I will only outline it. I used Ruby, SeleniumWebDriver, and the browser is Google Chrome.
A tool that automatically operates (tests) web applications on a web browser.
A mechanism to solve the problems of the old Selenium RC and operate the browser. Selenium RC is also called Selenium 1, and Selenium Web Driver is also called Selenium 2.
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G103
$ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin18]
$ gem install selenium-webdriver
Added Selenium Web Driver gem in terminal.
$ gem list
If selenium-webdriver is displayed, it's OK!
This time we will use Google Chrome in the browser, so install Chrome Driver from the link below.
I will write the code with an editor. I think that page transitions will differ depending on the university, so keep it simple. Since we are using Ruby this time, we will name it selenium_test.rb.
selenium_test.rb
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome
driver.manage.timeouts.implicit_wait = 60
#Specify the waiting time until the specified driver element is found
driver.navigate.to "URL"
#Access by specifying the URL
driver.find_element(:xpath, 'Describe the corresponding xpath').click
#Specify a button with xpath and press
driver.find_element(:name 'The name attribute you want to specify').send_keys('The word you want to enter')
#Specify the input form of name attribute and enter characters.
#After that, please use if statement, loop statement, etc. and create it according to the course registration of each university.
driver.quit
#Close driver
Execute with the following command.
$ ruby selenium_test.rb
Please point out any strange points! !!
Recommended Posts