Class: AutoFlick::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/auto_flick/api.rb

Class Method Summary collapse

Class Method Details

.get_key(auth_url, username, password) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/auto_flick/api.rb', line 24

def self.get_key(auth_url, username, password)
  begin
    visit auth_url

    fill_in('username', :with => username)
    fill_in('passwd', :with => password)
    click_button "login-signin"

    visit auth_url

    fill_in('username', :with => username)
    fill_in('passwd', :with => password)
    click_button "login-signin"

    click_button "OK, I'LL AUTHORIZE IT"  
    
    key = find("#Main span").text
    
  rescue Exception => e
    puts e.message
  end

  page.driver.quit
  File.delete("cookies.text")

  return key
end