test/ui_test_helper.rb
# helper to log into admin portion of site using supplied credentials
# Will also approve terms if not accepted yet, waits for redirect back to site, and closes modal
helper to log into admin portion of site using supplied credentials
Will also approve terms if not accepted yet, waits for redirect back to site, and closes modal
helper to log into admin portion of site using supplied credentials Will also approve terms if not accepted yet waits for redirect back to site and closes modal
def login(email, password)
    login_link = @driver.find_element(:id, 'login-nav')
    login_link.click
    $verbose ? puts('logging in as ' + email) : nil
    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
    @wait.until {@driver.execute_script("return PAGE_RENDERED;")}
    if element_present?(:id, 'notices-modal') && element_visible?(:id, 'notices-modal')
      $verbose ? puts('attempting to close notices-modal') : nil
      close_modal('notices-modal')
    end
    $verbose ? puts('login successful') : nil
  end
def login ( email , password ) login_link = @driver . find_element ( :id , 'login-nav' ) login_link . click $verbose ? puts ( 'logging in as ' + email ) : nil 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 @wait . until { @driver . execute_script ( "return PAGE_RENDERED;" ) } if element_present? ( :id , 'notices-modal' ) && element_visible? ( :id , 'notices-modal' ) $verbose ? puts ( 'attempting to close notices-modal' ) : nil close_modal ( 'notices-modal' ) end $verbose ? puts ( 'login successful' ) : nil end
helper to log into admin portion of site using supplied credentials
Will also approve terms if not accepted yet, waits for redirect back to site, and closes modal
helper to log into admin portion of site using supplied credentials Will also approve terms if not accepted yet waits for redirect back to site and closes modal
# 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>