Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b089b223
authored
Apr 04, 2015
by
Csók Tamás
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added more fallback actions
parent
8349fd0a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
10 deletions
+23
-10
circle/dashboard/tests/selenium/util.py
+23
-10
No files found.
circle/dashboard/tests/selenium/util.py
View file @
b089b223
...
...
@@ -37,15 +37,19 @@ logger = logging.getLogger(SeleniumConfig.logger_name)
class
SeleniumMixin
(
object
):
def
current_url
(
self
):
def
get_url
(
self
,
fragment_needed
=
False
,
fragment
=
None
):
url_base
=
urlparse
.
urlparse
(
self
.
driver
.
current_url
)
url_save
=
(
"
%(host)
s
%(url)
s"
%
{
'host'
:
self
.
conf
.
host
,
'url'
:
urlparse
.
urljoin
(
url_base
.
path
,
url_base
.
query
)})
if
url_base
.
fragment
:
if
fragment
is
None
:
fragment
=
url_base
.
fragment
else
:
fragment_needed
=
True
if
fragment_needed
and
fragment
:
url_save
=
(
"
%(url)
s#
%(fragment)
s"
%
{
'url'
:
url_save
,
'fragment'
:
url_base
.
fragment
})
'fragment'
:
fragment
})
return
url_save
def
list_options
(
self
,
select
):
...
...
@@ -255,7 +259,7 @@ class CircleSeleniumMixin(SeleniumMixin):
def
save_template_from_vm
(
self
,
name
):
try
:
url_save
=
self
.
curren
t_url
()
url_save
=
self
.
ge
t_url
()
WebDriverWait
(
self
.
driver
,
self
.
conf
.
wait_max_sec
)
.
until
(
ec
.
element_to_be_clickable
((
By
.
CSS_SELECTOR
,
...
...
@@ -412,7 +416,7 @@ class CircleSeleniumMixin(SeleniumMixin):
"""
try
:
if
restore
:
url_save
=
self
.
current_url
(
)
url_save
=
self
.
get_url
(
True
)
self
.
driver
.
get
(
'
%(host)
s/dashboard/vm/activity/
%(id)
s/'
%
{
'host'
:
self
.
conf
.
host
,
'id'
:
operation_id
})
...
...
@@ -488,7 +492,7 @@ class CircleSeleniumMixin(SeleniumMixin):
raise
Exception
(
'Cannot filter timeline activities to find most recent'
)
def
get_timeline_elements
(
self
,
code
=
None
):
def
get_timeline_elements
(
self
,
code
=
None
,
time_out_handle
=
True
):
try
:
if
code
is
None
:
css_activity_selector
=
"div[data-activity-code]"
...
...
@@ -498,12 +502,13 @@ class CircleSeleniumMixin(SeleniumMixin):
css_activity_selector
=
(
"div[data-activity-code="
"'
%(code)
s']"
%
{
'code'
:
code
})
self
.
click_on_link
(
WebDriverWait
(
self
.
driver
,
self
.
conf
.
wait_max_sec
)
.
until
(
ec
.
element_to_be_clickable
((
By
.
CSS_SELECTOR
,
"a[href*='#activity']"
))))
try
:
self
.
click_on_link
(
WebDriverWait
(
self
.
driver
,
self
.
conf
.
wait_max_sec
)
.
until
(
ec
.
element_to_be_clickable
((
By
.
CSS_SELECTOR
,
"a[href*='#activity']"
))))
activity_dict
=
{}
self
.
driver
.
save_screenshot
(
'activity.png'
)
timeline
=
WebDriverWait
(
self
.
driver
,
self
.
conf
.
wait_max_sec
)
.
until
(
ec
.
visibility_of_element_located
((
...
...
@@ -522,6 +527,14 @@ class CircleSeleniumMixin(SeleniumMixin):
except
StaleElementReferenceException
:
logger
.
warning
(
'Timeline changed while processing it'
)
return
self
.
get_timeline_elements
(
code
)
except
TimeoutException
:
logger
.
warning
(
'Can not found timeline in the page'
)
if
time_out_handle
:
self
.
driver
.
save_screenshot
(
'lost-timeline.png'
)
self
.
driver
.
get
(
self
.
get_url
(
fragment
=
'activity'
))
return
self
.
get_timeline_elements
(
code
,
False
)
else
:
raise
Exception
(
'Selenium could not locate the timeline'
)
except
:
logger
.
exception
(
'Selenium cannot get timeline elemets'
)
raise
Exception
(
'Cannot get timeline elements'
)
...
...
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