Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
15779d83
Unverified
Commit
15779d83
authored
May 23, 2018
by
Bryce Taylor
Committed by
GitHub
May 23, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1888 from BryceLTaylor/Selenium-login-failure-tests
Selenium login failure tests
parents
f19a6c61
86e9549c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
32 deletions
+35
-32
test/integration/selenium-helpers.js
test/integration/selenium-helpers.js
+5
-0
test/integration/smoke-testing/test-login-failures.js
test/integration/smoke-testing/test-login-failures.js
+30
-32
No files found.
test/integration/selenium-helpers.js
View file @
15779d83
...
...
@@ -30,6 +30,10 @@ const findByCss = (css) => {
return
driver
.
wait
(
until
.
elementLocated
(
By
.
css
(
css
),
1000
*
5
));
};
const
clickCss
=
(
css
)
=>
{
return
findByCss
(
css
).
then
(
el
=>
el
.
click
());
};
const
getLogs
=
(
whitelist
)
=>
{
return
driver
.
manage
()
.
logs
()
...
...
@@ -65,5 +69,6 @@ module.exports = {
findText
,
clickButton
,
findByCss
,
clickCss
,
getLogs
};
test/integration/smoke-testing/test-login-failures.js
View file @
15779d83
const
{
clickText
,
findByXpath
,
clickButton
,
driver
,
until
,
By
findByCss
,
clickCss
,
until
}
=
require
(
'
../selenium-helpers.js
'
);
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
)
.
replace
(
/
[^
a-z
]
+/g
,
''
)
.
substr
(
0
,
5
);
click
Text
(
'
Sign in
'
)
.
then
(()
=>
findBy
Xpath
(
'
//input[@id="login_dropdown_username"]
'
))
click
Css
(
'
.dropdown-toggle
'
)
.
then
(()
=>
findBy
Css
(
'
form#login input#login_dropdown_username
'
))
.
then
((
element
)
=>
element
.
sendKeys
(
nonsenseusername
))
.
then
(()
=>
click
Button
(
'
Sign i
n
'
))
.
then
(()
=>
driver
.
wait
(
until
.
elementLocated
(
By
.
xpath
(
'
//form[@id="login"]/button[@type="submit"]
'
))))
.
then
(()
=>
driver
.
wait
(
until
.
elementLocated
(
By
.
xpath
(
'
//form[@id="login"]/div[@class="error"]
'
))))
.
then
(()
=>
findByXpath
(
'
//form/div[@class="error"]
'
)
)
.
then
(()
=>
click
Css
(
'
form#login butto
n
'
))
.
then
(()
=>
findByCss
(
'
form#login .error
'
))
.
then
((
element
)
=>
{
driver
.
wait
(
until
.
elementIsVisible
(
element
));
return
element
;
}
)
.
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
'
))
.
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
)
.
replace
(
/
[^
a-z
]
+/g
,
''
)
.
substr
(
0
,
5
);
click
Text
(
'
Sign in
'
)
.
then
(()
=>
findBy
Xpath
(
'
//input[@id="login_dropdown_username"]
'
))
click
Css
(
'
.dropdown-toggle
'
)
.
then
(()
=>
findBy
Css
(
'
form#login input#login_dropdown_username
'
))
.
then
((
element
)
=>
element
.
sendKeys
(
nonsenseusername
))
.
then
(()
=>
findBy
Xpath
(
'
//input[@name="password"]
'
))
.
then
(()
=>
findBy
Css
(
'
form#login input.wide.password
'
))
.
then
((
element
)
=>
element
.
sendKeys
(
password
))
.
then
(()
=>
click
Button
(
'
Sign i
n
'
))
.
then
(()
=>
driver
.
wait
(
until
.
elementLocated
(
By
.
xpath
(
'
//form[@id="login"]/button[@type="submit"]
'
))))
.
then
(()
=>
driver
.
wait
(
until
.
elementLocated
(
By
.
xpath
(
'
//form[@id="login"]/div[@class="error"]
'
))))
.
then
(()
=>
findByXpath
(
'
//form/div[@class="error"]
'
)
)
.
then
(()
=>
click
Css
(
'
form#login butto
n
'
))
.
then
(()
=>
findByCss
(
'
form#login .error
'
))
.
then
((
element
)
=>
{
driver
.
wait
(
until
.
elementIsVisible
(
element
));
return
element
;
}
)
.
then
((
element
)
=>
element
.
getText
())
.
then
((
text
)
=>
t
.
match
(
text
,
'
Incorrect username or password.
'
,
'
"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
=>
{
click
Text
(
'
Sign in
'
)
.
then
(()
=>
findBy
Xpath
(
'
//input[@id="login_dropdown_username"]
'
))
click
Css
(
'
.dropdown-toggle
'
)
.
then
(()
=>
findBy
Css
(
'
form#login input#login_dropdown_username
'
))
.
then
((
element
)
=>
element
.
sendKeys
(
username
))
.
then
(()
=>
findBy
Xpath
(
'
//input[@name="password"]
'
))
.
then
(()
=>
findBy
Css
(
'
form#login input.wide.password
'
))
.
then
((
element
)
=>
element
.
sendKeys
(
'
nonsensepassword
'
))
.
then
(()
=>
click
Button
(
'
Sign i
n
'
))
.
then
(()
=>
driver
.
wait
(
until
.
elementLocated
(
By
.
xpath
(
'
//form[@id="login"]/button[@type="submit"]
'
))))
.
then
(()
=>
driver
.
wait
(
until
.
elementLocated
(
By
.
xpath
(
'
//form[@id="login"]/div[@class="error"]
'
))))
.
then
(()
=>
findByXpath
(
'
//form/div[@class="error"]
'
)
)
.
then
(()
=>
click
Css
(
'
form#login butto
n
'
))
.
then
(()
=>
findByCss
(
'
form#login .error
'
))
.
then
((
element
)
=>
{
driver
.
wait
(
until
.
elementIsVisible
(
element
));
return
element
;
}
)
.
then
((
element
)
=>
element
.
getText
())
.
then
((
text
)
=>
t
.
match
(
text
,
'
Incorrect username or password.
'
,
'
"Incorrect username or password" error should be displayed
'
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment