Last active
December 11, 2015 16:58
-
-
Save Cellane/4630834 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
#!/usr/bin/ruby | |
# Created in 2013 by Milan Vit <[email protected]> | |
# Licensed under Creative Commons BY-NC-SA 3.0 licence, available at: | |
# http://creativecommons.org/licenses/by-nc-sa/3.0/cz/ | |
require 'rubygems' | |
require 'watir' | |
require 'watir-webdriver' | |
# Put login details & current semester here | |
# No further edits are needed until line 55 | |
# Valid values for the semester variable are 'L'/'S' => summer, anything else => winter | |
username = '' | |
password = '' | |
semester = 'L' | |
b = Watir::Browser.new | |
b.goto 'portal.osu.cz' | |
b.text_field(:id => 'userID').set username | |
b.text_field(:id => 'password').set password | |
t = b.button(:value => 'Log in') | |
if t.exists? then | |
t.click | |
else | |
b.button(:value => 'Přihlásit').click | |
end | |
l = b.link(:text => 'Moje stránka - Studium - Hodnocení kvality') | |
if l.exists? then | |
l.click | |
else | |
b.link(:text => 'Elektronický index').click | |
end | |
b.link(:text => 'Předzápis').click | |
s = b.select_list :id => 'rozvrhSemestr' | |
if s.exists? then | |
if semester == 'L' or semester == 'S' then | |
if s.option(:text => 'Summer semester').exists? then | |
s.select 'Summer semester' | |
else | |
s.select 'Letní semestr' | |
end | |
else | |
if s.option(:text => 'Winter semester').exists? then | |
s.select 'Winter semester' | |
else | |
s.select 'Zimní semestr' | |
end | |
end | |
end | |
# Instruct the script what kind of changes you wish to perform | |
b.link(:text => 'KIP/APNVZ').click | |
b.div(:text => '7:30 (1)').when_present.parent.parent.cell(:index => 8).checkbox.set | |
b.div(:text => '0:00').when_present.parent.parent.cell(:index => 8).checkbox.clear | |
b.button(:text => 'Uložit změny').click | |
b.link(:text => 'KIP/GVEMD').click | |
b.div(:text => '15:50 (11)').when_present.parent.parent.cell(:index => 8).checkbox.set | |
b.div(:text => '0:00').when_present.parent.parent.cell(:index => 8).checkbox.clear | |
b.button(:text => 'Uložit změny').click |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment