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
# 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"
    
    click_button "OK, I'LL AUTHORIZE IT"  

    key = find("#Main span").text

  rescue Capybara::ElementNotFound => e
    retry
  ensure
    page.driver.quit
    File.delete("cookies.text")  
  end

  return key
end