Last active
September 26, 2019 05:49
-
-
Save zewa666/163bcd9b0e84498379ef33a245e40d8b to your computer and use it in GitHub Desktop.
samples
This file contains hidden or 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
def test_check_credentials(self): | |
driver = self.get_driver() | |
username = (By.CSS_SELECTOR, "#username") | |
password = (By.CSS_SELECTOR, "#password") | |
login = (By.CSS_SELECTOR, "[class=\'fa fa-2x fa-sign-in\']") | |
result_message = (By.CSS_SELECTOR, "#flash") | |
wait = WebDriverWait(driver, 10) | |
# Open the Web Page | |
driver.get('https://the-internet.herokuapp.com/login') | |
# Attempt to log in | |
wait.until(EC.visibility_of_element_located(username)).send_keys("username") | |
wait.until(EC.visibility_of_element_located(password)).send_keys("password") | |
wait.until(EC.visibility_of_element_located(login)).click() | |
# Capture the login message after clicking the button | |
result = wait.until(EC.visibility_of_element_located(result_message)).text.replace("×", "").strip() | |
self.assertEqual(result, "Your username is invalid!") |
This file contains hidden or 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
it('should check credentials', async () => { | |
const username = by.css('#username'); | |
const password = by.css('#password'); | |
const login = by.css('[class=\'fa fa-2x fa-sign-in\']'); | |
const resultMessage = by.css('#flash'); | |
// Open the Web Page | |
await browser.driver.get('https://the-internet.herokuapp.com/login'); | |
// Attempt to log in | |
await browser.wait(ExpectedConditions.visibilityOf(element(username)), browser.allScriptsTimeout, username.toString()); | |
await element(username).sendKeys('username'); | |
await browser.wait(ExpectedConditions.visibilityOf(element(password)), browser.allScriptsTimeout, password.toString()); | |
await element(password).sendKeys('password'); | |
await browser.wait(ExpectedConditions.visibilityOf(element(login)), browser.allScriptsTimeout, login.toString()); | |
await element(login).click(); | |
// Capture the login message after clicking the button | |
await browser.wait(ExpectedConditions.visibilityOf(element(resultMessage)), browser.allScriptsTimeout, resultMessage.toString()); | |
const result = await element(resultMessage).getText().then((m) => m.replace(/×/g, '').trim()); | |
await expect(result).toEqual('Your username is invalid!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment