Created
February 22, 2018 10:27
-
-
Save ch1c0t/1d5ac12f647bfd16596346bab4bc51cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'watir' | |
class LoginPage | |
def initialize browser, url = 'https://www.linkedin.com/uas/login' | |
@browser, @url = browser, url | |
end | |
def sign_in_with login, password | |
@browser.goto @url | |
@browser.input(id: 'session_key-login').send_keys login | |
@browser.input(id: 'session_password-login').send_keys password | |
@browser.input(id: 'btn-primary').click | |
end | |
def error_occurred? | |
@browser.text.include? "There were one or more errors in your submission." | |
end | |
def logged_in? | |
@browser.url == 'https://www.linkedin.com/feed/?trk=' | |
end | |
end | |
login_page = LoginPage.new Watir::Browser.new | |
login_page.sign_in_with '[email protected]', 'some password' | |
login_page.error_occurred? #=> true | |
login_page.logged_in? #=> false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment