-
-
Save trungx/0bd49921a5a7904f5ac85d567301da50 to your computer and use it in GitHub Desktop.
gigacube-reboot.rb
This file contains hidden or 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/env ruby | |
# Author : Ky-Anh Huynh | |
# License : MIT | |
# Date : 2020-05-02 | |
# Usage : | |
# | |
# $ gem install watir headless | |
# $ pacman -s xvfb | |
# $ PASSWORD="your_router_password" ./restart.rb | |
# | |
# Ref: | |
# | |
# https://www.rubyguides.com/2019/01/ruby-watir-gem/ | |
# http://watir.com/guides/headless/ | |
require 'watir' | |
require 'headless' | |
my_password = ENV["PASSWORD"].to_s | |
Watir.default_timeout = 15 | |
Selenium::WebDriver.logger.level = :error | |
headless = Headless.new | |
headless.start | |
browser = Watir::Browser.new | |
browser.goto("http://192.168.8.1") | |
browser.div(class: %w{guide_eye ic_eye_close}).click | |
browser.text_field(id: "login_password_text").value = my_password | |
browser.div(id: "login_btn").click | |
browser.div(class: "ic_reboot").click | |
# Cancel | |
# browser.div(class: %w{btn_normal_short pull-left public_reboot_left}).click | |
# browser.div(onclick: "EMUI.RebootController.rebootCancel()").click | |
# Reboot | |
browser.div(onclick: "EMUI.RebootController.rebootExe()").click | |
headless.destroy | |
puts "Bye" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment