Skip to content

Instantly share code, notes, and snippets.

@boatcoder
Created September 29, 2020 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boatcoder/663e9abeca74dca7d6f1b8fa663b10a1 to your computer and use it in GitHub Desktop.
Save boatcoder/663e9abeca74dca7d6f1b8fa663b10a1 to your computer and use it in GitHub Desktop.
A simple test using the PageElements
from selenium.webdriver.support.ui import WebDriverWait
import pages
def test_login_with_invalid_credentials(login_url):
try:
driver = get_browser()
driver.get(login_url)
login_page = pages.LoginPage(driver)
# Can't use this method here since we want to actually test the various aspects of
# logging in and failing to log in
# login_page.login() - Use this in other tests where you just need to login to do the
# test
login_page.username = XXXXXXXX
login_page.password = XXXXXXXX
login_page.click_login_button()
assert(login_page.error_message.text == 'Invalid email or password. Please try again.')
assert(driver.current_url == login_url)
finally:
logger.info('Quitting browser')
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment