mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-22 23:27:54 -05:00
Merge pull request #1888 from BryceLTaylor/Selenium-login-failure-tests
Selenium login failure tests
This commit is contained in:
commit
15779d833e
2 changed files with 35 additions and 32 deletions
|
@ -30,6 +30,10 @@ const findByCss = (css) => {
|
||||||
return driver.wait(until.elementLocated(By.css(css), 1000 * 5));
|
return driver.wait(until.elementLocated(By.css(css), 1000 * 5));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const clickCss = (css) => {
|
||||||
|
return findByCss(css).then(el => el.click());
|
||||||
|
};
|
||||||
|
|
||||||
const getLogs = (whitelist) => {
|
const getLogs = (whitelist) => {
|
||||||
return driver.manage()
|
return driver.manage()
|
||||||
.logs()
|
.logs()
|
||||||
|
@ -65,5 +69,6 @@ module.exports = {
|
||||||
findText,
|
findText,
|
||||||
clickButton,
|
clickButton,
|
||||||
findByCss,
|
findByCss,
|
||||||
|
clickCss,
|
||||||
getLogs
|
getLogs
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
const {
|
const {
|
||||||
clickText,
|
|
||||||
findByXpath,
|
|
||||||
clickButton,
|
|
||||||
driver,
|
driver,
|
||||||
until,
|
findByCss,
|
||||||
By
|
clickCss,
|
||||||
|
until
|
||||||
} = require('../selenium-helpers.js');
|
} = require('../selenium-helpers.js');
|
||||||
|
|
||||||
var username = process.env.SMOKE_USERNAME;
|
var username = process.env.SMOKE_USERNAME;
|
||||||
|
@ -31,17 +29,17 @@ test('Trying to sign in with no password using scratchr2 navbar', t => {
|
||||||
var nonsenseusername = Math.random().toString(36)
|
var nonsenseusername = Math.random().toString(36)
|
||||||
.replace(/[^a-z]+/g, '')
|
.replace(/[^a-z]+/g, '')
|
||||||
.substr(0, 5);
|
.substr(0, 5);
|
||||||
clickText('Sign in')
|
clickCss('.dropdown-toggle')
|
||||||
.then(() => findByXpath('//input[@id="login_dropdown_username"]'))
|
.then(() => findByCss('form#login input#login_dropdown_username'))
|
||||||
.then((element) => element.sendKeys(nonsenseusername))
|
.then((element) => element.sendKeys(nonsenseusername))
|
||||||
.then(() => clickButton('Sign in'))
|
.then(() => clickCss('form#login button'))
|
||||||
.then(() => driver.wait(until
|
.then(() => findByCss('form#login .error'))
|
||||||
.elementLocated(By.xpath('//form[@id="login"]/button[@type="submit"]'))))
|
.then((element) => {
|
||||||
.then(() => driver.wait(until
|
driver.wait(until.elementIsVisible(element));
|
||||||
.elementLocated(By.xpath('//form[@id="login"]/div[@class="error"]'))))
|
return element;
|
||||||
.then(() => findByXpath('//form/div[@class="error"]'))
|
})
|
||||||
.then((element) => element.getText())
|
.then((element) => element.getText())
|
||||||
.then((text) => t.match(text, 'This field is required.',
|
.then((text) => t.match(text, 'This field is required',
|
||||||
'"This field is required" error should be displayed'))
|
'"This field is required" error should be displayed'))
|
||||||
.then(() => t.end());
|
.then(() => t.end());
|
||||||
});
|
});
|
||||||
|
@ -50,17 +48,17 @@ test('Trying to sign in with the wrong username using scratchr2 navbar', t => {
|
||||||
var nonsenseusername = Math.random().toString(36)
|
var nonsenseusername = Math.random().toString(36)
|
||||||
.replace(/[^a-z]+/g, '')
|
.replace(/[^a-z]+/g, '')
|
||||||
.substr(0, 5);
|
.substr(0, 5);
|
||||||
clickText('Sign in')
|
clickCss('.dropdown-toggle')
|
||||||
.then(() => findByXpath('//input[@id="login_dropdown_username"]'))
|
.then(() => findByCss('form#login input#login_dropdown_username'))
|
||||||
.then((element) => element.sendKeys(nonsenseusername))
|
.then((element) => element.sendKeys(nonsenseusername))
|
||||||
.then(() => findByXpath('//input[@name="password"]'))
|
.then(() => findByCss('form#login input.wide.password'))
|
||||||
.then((element) => element.sendKeys(password))
|
.then((element) => element.sendKeys(password))
|
||||||
.then(() => clickButton('Sign in'))
|
.then(() => clickCss('form#login button'))
|
||||||
.then(() => driver.wait(until
|
.then(() => findByCss('form#login .error'))
|
||||||
.elementLocated(By.xpath('//form[@id="login"]/button[@type="submit"]'))))
|
.then((element) => {
|
||||||
.then(() => driver.wait(until
|
driver.wait(until.elementIsVisible(element));
|
||||||
.elementLocated(By.xpath('//form[@id="login"]/div[@class="error"]'))))
|
return element;
|
||||||
.then(() => findByXpath('//form/div[@class="error"]'))
|
})
|
||||||
.then((element) => element.getText())
|
.then((element) => element.getText())
|
||||||
.then((text) => t.match(text, 'Incorrect username or password.',
|
.then((text) => t.match(text, 'Incorrect username or password.',
|
||||||
'"Incorrect username or password" error should be displayed'))
|
'"Incorrect username or password" error should be displayed'))
|
||||||
|
@ -68,17 +66,17 @@ test('Trying to sign in with the wrong username using scratchr2 navbar', t => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Trying to sign in with the wrong password using scratchr2 navbar', t => {
|
test('Trying to sign in with the wrong password using scratchr2 navbar', t => {
|
||||||
clickText('Sign in')
|
clickCss('.dropdown-toggle')
|
||||||
.then(() => findByXpath('//input[@id="login_dropdown_username"]'))
|
.then(() => findByCss('form#login input#login_dropdown_username'))
|
||||||
.then((element) => element.sendKeys(username))
|
.then((element) => element.sendKeys(username))
|
||||||
.then(() => findByXpath('//input[@name="password"]'))
|
.then(() => findByCss('form#login input.wide.password'))
|
||||||
.then((element) => element.sendKeys('nonsensepassword'))
|
.then((element) => element.sendKeys('nonsensepassword'))
|
||||||
.then(() => clickButton('Sign in'))
|
.then(() => clickCss('form#login button'))
|
||||||
.then(() => driver.wait(until
|
.then(() => findByCss('form#login .error'))
|
||||||
.elementLocated(By.xpath('//form[@id="login"]/button[@type="submit"]'))))
|
.then((element) => {
|
||||||
.then(() => driver.wait(until
|
driver.wait(until.elementIsVisible(element));
|
||||||
.elementLocated(By.xpath('//form[@id="login"]/div[@class="error"]'))))
|
return element;
|
||||||
.then(() => findByXpath('//form/div[@class="error"]'))
|
})
|
||||||
.then((element) => element.getText())
|
.then((element) => element.getText())
|
||||||
.then((text) => t.match(text, 'Incorrect username or password.',
|
.then((text) => t.match(text, 'Incorrect username or password.',
|
||||||
'"Incorrect username or password" error should be displayed'))
|
'"Incorrect username or password" error should be displayed'))
|
||||||
|
|
Loading…
Reference in a new issue