Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
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)
...
@@ -37,15 +37,19 @@ logger = logging.getLogger(SeleniumConfig.logger_name)
class
SeleniumMixin
(
object
):
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_base
=
urlparse
.
urlparse
(
self
.
driver
.
current_url
)
url_save
=
(
"
%(host)
s
%(url)
s"
%
{
url_save
=
(
"
%(host)
s
%(url)
s"
%
{
'host'
:
self
.
conf
.
host
,
'host'
:
self
.
conf
.
host
,
'url'
:
urlparse
.
urljoin
(
url_base
.
path
,
url_base
.
query
)})
'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_save
=
(
"
%(url)
s#
%(fragment)
s"
%
{
'url'
:
url_save
,
'url'
:
url_save
,
'fragment'
:
url_base
.
fragment
})
'fragment'
:
fragment
})
return
url_save
return
url_save
def
list_options
(
self
,
select
):
def
list_options
(
self
,
select
):
...
@@ -255,7 +259,7 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -255,7 +259,7 @@ class CircleSeleniumMixin(SeleniumMixin):
def
save_template_from_vm
(
self
,
name
):
def
save_template_from_vm
(
self
,
name
):
try
:
try
:
url_save
=
self
.
curren
t_url
()
url_save
=
self
.
ge
t_url
()
WebDriverWait
(
self
.
driver
,
self
.
conf
.
wait_max_sec
)
.
until
(
WebDriverWait
(
self
.
driver
,
self
.
conf
.
wait_max_sec
)
.
until
(
ec
.
element_to_be_clickable
((
ec
.
element_to_be_clickable
((
By
.
CSS_SELECTOR
,
By
.
CSS_SELECTOR
,
...
@@ -412,7 +416,7 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -412,7 +416,7 @@ class CircleSeleniumMixin(SeleniumMixin):
"""
"""
try
:
try
:
if
restore
:
if
restore
:
url_save
=
self
.
current_url
(
)
url_save
=
self
.
get_url
(
True
)
self
.
driver
.
get
(
'
%(host)
s/dashboard/vm/activity/
%(id)
s/'
%
{
self
.
driver
.
get
(
'
%(host)
s/dashboard/vm/activity/
%(id)
s/'
%
{
'host'
:
self
.
conf
.
host
,
'host'
:
self
.
conf
.
host
,
'id'
:
operation_id
})
'id'
:
operation_id
})
...
@@ -488,7 +492,7 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -488,7 +492,7 @@ class CircleSeleniumMixin(SeleniumMixin):
raise
Exception
(
raise
Exception
(
'Cannot filter timeline activities to find most recent'
)
'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
:
try
:
if
code
is
None
:
if
code
is
None
:
css_activity_selector
=
"div[data-activity-code]"
css_activity_selector
=
"div[data-activity-code]"
...
@@ -498,12 +502,13 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -498,12 +502,13 @@ class CircleSeleniumMixin(SeleniumMixin):
css_activity_selector
=
(
"div[data-activity-code="
css_activity_selector
=
(
"div[data-activity-code="
"'
%(code)
s']"
%
{
"'
%(code)
s']"
%
{
'code'
:
code
})
'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
:
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
=
{}
activity_dict
=
{}
self
.
driver
.
save_screenshot
(
'activity.png'
)
timeline
=
WebDriverWait
(
timeline
=
WebDriverWait
(
self
.
driver
,
self
.
conf
.
wait_max_sec
)
.
until
(
self
.
driver
,
self
.
conf
.
wait_max_sec
)
.
until
(
ec
.
visibility_of_element_located
((
ec
.
visibility_of_element_located
((
...
@@ -522,6 +527,14 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -522,6 +527,14 @@ class CircleSeleniumMixin(SeleniumMixin):
except
StaleElementReferenceException
:
except
StaleElementReferenceException
:
logger
.
warning
(
'Timeline changed while processing it'
)
logger
.
warning
(
'Timeline changed while processing it'
)
return
self
.
get_timeline_elements
(
code
)
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
:
except
:
logger
.
exception
(
'Selenium cannot get timeline elemets'
)
logger
.
exception
(
'Selenium cannot get timeline elemets'
)
raise
Exception
(
'Cannot get timeline elements'
)
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