Skip to content

Instantly share code, notes, and snippets.

@wm
Forked from drinks/hangout
Last active December 12, 2015 02:48
Show Gist options
  • Save wm/4701910 to your computer and use it in GitHub Desktop.
Save wm/4701910 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
### make sure you `brew install chromedriver` and `gem install selenium-webdriver` before running this!
require 'rubygems'
require 'selenium-webdriver'
hangout_url = ENV['hangout_url']
hangout_email = ENV['hangout_email']
hangout_password = ENV['hangout_password']
# maximize this mofo
profile = Selenium::WebDriver::Chrome::Profile.new
profile['browser.window_placement.top'] = 0
profile['browser.window_placement.left'] = 0
profile['browser.window_placement.right'] = 1280 # or whatever your display resolution is...
profile['browser.window_placement.bottom'] = 720
# go to stupid splash screen
browser = Selenium::WebDriver.for :chrome, :profile => profile
wait = Selenium::WebDriver::Wait.new :timetout => 20
browser.navigate.to hangout_url
# browser.find_element(:class, 'gQb').click
# log in to g+
wait.until { browser.find_element(:id => 'Email') }
browser.find_element(:id, 'Email').send_keys(hangout_email)
browser.find_element(:id, 'Passwd').send_keys(hangout_password)
browser.find_element(:id, 'signIn').click
# log in to hangout
# Note that the class here may change often so there may be a better way to do this.
wait.until { browser.find_elements(:class, 'IA')[0] }
wait.until { browser.find_elements(:class, 'IA')[0].displayed? }
browser.find_elements(:class, 'IA')[0].click
### Tell the AppleScript to put chrome in the foreground after running this!
#!/bin/bash
source ~/.hangout_credentials
ruby ~/hangout.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment