Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
grady
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Maximilian Michal
grady
Commits
4af305e9
Commit
4af305e9
authored
6 years ago
by
robinwilliam.hundt
Browse files
Options
Downloads
Patches
Plain Diff
Removed explicit waits in functional tests
parent
4c008882
No related branches found
No related tags found
No related merge requests found
Pipeline
#86638
passed
6 years ago
Stage: build
Stage: test
Stage: build_image
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
functional_tests/test_front_pages.py
+11
-3
11 additions, 3 deletions
functional_tests/test_front_pages.py
functional_tests/test_login_page.py
+6
-5
6 additions, 5 deletions
functional_tests/test_login_page.py
functional_tests/util.py
+3
-0
3 additions, 0 deletions
functional_tests/util.py
with
20 additions
and
8 deletions
functional_tests/test_front_pages.py
+
11
−
3
View file @
4af305e9
import
time
from
django.test
import
LiveServerTestCase
from
selenium
import
webdriver
from
selenium.webdriver.support.ui
import
WebDriverWait
from
core
import
models
from
core.models
import
UserAccount
...
...
@@ -47,11 +46,20 @@ class UntestedParent:
self
.
assertEqual
(
'
Statistics
'
,
title
.
text
)
def
test_available_tasks_are_shown
(
self
):
# A function that takes the element corresponding to the tasks
# component and return a function that can be used as a condition for
# WebDriverWait
def
subscriptions_loaded_cond
(
tasks_el
):
def
loaded
(
*
args
):
sub_links
=
tasks_el
.
find_elements_by_tag_name
(
'
a
'
)
return
any
((
link
!=
'
/home
'
for
link
in
extract_hrefs_hashes
(
sub_links
)))
return
loaded
self
.
_login
()
tasks
=
self
.
browser
.
find_element_by_name
(
'
subscription-list
'
)
title
=
tasks
.
find_element_by_class_name
(
'
v-toolbar__title
'
)
self
.
assertEqual
(
'
Tasks
'
,
title
.
text
)
time
.
sleep
(
8
)
WebDriverWait
(
self
.
browser
,
6
).
until
(
subscriptions_loaded_cond
(
tasks
)
)
subscription_links
=
extract_hrefs_hashes
(
tasks
.
find_elements_by_tag_name
(
'
a
'
)
)
...
...
This diff is collapsed.
Click to expand it.
functional_tests/test_login_page.py
+
6
−
5
View file @
4af305e9
import
time
from
django.test
import
LiveServerTestCase
from
selenium
import
webdriver
from
selenium.webdriver.common.keys
import
Keys
from
selenium.webdriver.support
import
expected_conditions
as
ec
from
selenium.webdriver.support.ui
import
WebDriverWait
from
core.models
import
UserAccount
from
util.factories
import
make_test_data
...
...
@@ -102,7 +102,7 @@ class LoginPageTest(LiveServerTestCase):
password_input
=
self
.
browser
.
find_element_by_xpath
(
'
//input[@aria-label=
"
Password
"
]
'
)
password_input
.
send_keys
(
'
p
'
)
self
.
browser
.
find_element_by_xpath
(
'
//button[@type=
"
submit
"
]
'
).
send_keys
(
Keys
.
ENTER
)
time
.
sleep
(
1
)
WebDriverWait
(
self
.
browser
,
3
).
until
(
ec
.
url_contains
(
'
/home
'
)
)
def
test_tutor_can_login
(
self
):
tutor
=
self
.
test_data
[
'
tutors
'
][
0
]
...
...
@@ -130,8 +130,9 @@ class LoginPageTest(LiveServerTestCase):
username_input
.
send_keys
(
username
)
password_input
=
self
.
browser
.
find_element_by_id
(
'
input-register-password
'
)
password_input
.
send_keys
(
password
)
self
.
browser
.
find_element_by_id
(
'
register-submit
'
).
click
()
time
.
sleep
(
1
)
register_submit_el
=
self
.
browser
.
find_element_by_id
(
'
register-submit
'
)
register_submit_el
.
click
()
WebDriverWait
(
self
.
browser
,
3
).
until_not
(
ec
.
visibility_of
(
register_submit_el
))
tutor
=
UserAccount
.
objects
.
get
(
username
=
username
)
self
.
assertEqual
(
UserAccount
.
TUTOR
,
tutor
.
role
)
self
.
assertFalse
(
tutor
.
is_active
,
"
Tutors should be inactive after registered
"
)
This diff is collapsed.
Click to expand it.
functional_tests/util.py
+
3
−
0
View file @
4af305e9
...
...
@@ -6,6 +6,8 @@ from selenium import webdriver
from
selenium.webdriver.common.keys
import
Keys
from
selenium.webdriver.firefox.options
import
Options
from
selenium.webdriver.remote.webelement
import
WebElement
from
selenium.webdriver.support
import
expected_conditions
as
ec
from
selenium.webdriver.support.ui
import
WebDriverWait
def
create_browser
()
->
webdriver
.
Firefox
:
...
...
@@ -23,6 +25,7 @@ def login(browser, live_server_url, username, password='p'):
password_input
=
browser
.
find_element_by_xpath
(
'
//input[@aria-label=
"
Password
"
]
'
)
password_input
.
send_keys
(
password
)
browser
.
find_element_by_xpath
(
'
//button[@type=
"
submit
"
]
'
).
send_keys
(
Keys
.
ENTER
)
WebDriverWait
(
browser
,
3
).
until
(
ec
.
url_contains
(
'
/home
'
))
def
reset_browser_after_test
(
browser
:
webdriver
.
Firefox
,
live_server_url
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment