test/ui_test_helper.rb
# method to log out of google so that we can log in with a different account
method to log out of google so that we can log in with a different account
method to log out of google so that we can log in with a different account
def login_as_other(email, password)
    invalidate_google_session
    @driver.get @base_url
    login_link = @driver.find_element(:id, 'login-nav')
    login_link.click
    $verbose ? puts('logging in as ' + email) : nil
    use_new = @driver.find_element(:id, 'identifierLink')
    use_new.click
    wait_for_render(:id, 'identifierId')
    sleep(1)
    complete_login_process(email, password)
    @not_loaded = true
    while @not_loaded == true
      begin
        loaded = @driver.execute_script("return elementVisible('.footer')")
        if loaded == true
          @not_loaded = false
        end
        sleep(1)
      rescue Selenium::WebDriver::Error::UnknownError
        if @driver.current_url.include?('https://accounts.google.com/signin/oauth/consent')
          $verbose ? puts('approving access') : nil
          approve = @driver.find_element(:id, 'submit_approve_access')
          @clickable = approve['disabled'].nil?
          while @clickable != true
            sleep(1)
            @clickable = @driver.find_element(:id, 'submit_approve_access')['disabled'].nil?
          end
          approve.click
          $verbose ? puts('access approved') : nil
        end
        sleep(1)
      end
    end
    if element_present?(:id, 'notices-modal') && element_visible?(:id, 'notices-modal')
      close_modal('notices-modal')
    end
    $verbose ? puts('login successful') : nil
  end
def login_as_other ( email , password ) invalidate_google_session @driver . get @base_url login_link = @driver . find_element ( :id , 'login-nav' ) login_link . click $verbose ? puts ( 'logging in as ' + email ) : nil use_new = @driver . find_element ( :id , 'identifierLink' ) use_new . click wait_for_render ( :id , 'identifierId' ) sleep ( 1 ) complete_login_process ( email , password ) @not_loaded = true while @not_loaded == true begin loaded = @driver . execute_script ( "return elementVisible('.footer')" ) if loaded == true @not_loaded = false end sleep ( 1 ) rescue Selenium :: WebDriver :: Error :: UnknownError if @driver . current_url . include? ( 'https://accounts.google.com/signin/oauth/consent' ) $verbose ? puts ( 'approving access' ) : nil approve = @driver . find_element ( :id , 'submit_approve_access' ) @clickable = approve [ 'disabled' ] . nil? while @clickable != true sleep ( 1 ) @clickable = @driver . find_element ( :id , 'submit_approve_access' ) [ 'disabled' ] . nil? end approve . click $verbose ? puts ( 'access approved' ) : nil end sleep ( 1 ) end end if element_present? ( :id , 'notices-modal' ) && element_visible? ( :id , 'notices-modal' ) close_modal ( 'notices-modal' ) end $verbose ? puts ( 'login successful' ) : nil end
method to log out of google so that we can log in with a different account
method to log out of google so that we can log in with a different account
# fill out login form # wait for redirect to finish by checking for footer element # we need to return the result of the script to store its value # check to make sure if we need to accept terms first to complete login
email
<not_specific>
password
<not_specific>