Last active
August 16, 2018 15:36
-
-
Save maksymilian-majer/797fa346a8a94eee5633ad0b36e284f1 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
// Protractor: | |
it('Should show invalid username or password', () => { | |
browser.get("/wp-login.php"); | |
var inputField = element(by.xpath("//label[. = 'Username or Email Address']/following-sibling::input")); | |
inputField.sendKeys("maks"); | |
inputField = element(by.xpath("//label[. = 'Password']/following-sibling::input")); | |
inputField.sendKeys("some wrong psw"); | |
element(by.buttonText('Log In')).click(); | |
var errorMsg = element(by.id('messages')); | |
expect(errorMsg.getText()).toEqual('ERROR: Invalid username. Lost your password?'); | |
}); | |
// NightmareJS | |
it('Should show invalid username or password', async () => { | |
await text = nightmare | |
.goto('/wp-login.php') | |
.type('#username', 'maks') | |
.type('#password', 'some wrong psw') | |
.click('form [type=button]') | |
.wait('#messages') | |
.evaluate(function () { | |
return document.querySelector('#messages').innerText; | |
}); | |
await nightmare.end() | |
expect(text).toEqual('ERROR: Invalid username. Lost your password?'); | |
}); | |
// Puppeteer: | |
it('Should show invalid username or password', async () => { | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.goto('/wp-login.php'); | |
await page.click('#user_login'); | |
await page.keyboard.type('maks'); | |
await page.click('#user_pass'); | |
await page.keyboard.type('some wrong psw'); | |
await page.click('#wp-submit'); | |
await page.waitFor(1000); | |
const text = await page.evaluate(() => document.querySelector('#login_error').textContent); | |
await browser.close(); | |
expect(text).toEqual('ERROR: Invalid username. Lost your password?'); | |
}); | |
// CodeceptJS: | |
Scenario('Invalid username or password', (I) => { | |
I.amOnPage('/wp-login.php'); | |
I.fillField('Username or Email Address', 'maks'); | |
I.fillField('Password', 'some wrong psw'); | |
I.click('Log In'); | |
I.see('ERROR: Invalid username. Lost your password?'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment