Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos
Commits
dedbc5ec
Commit
dedbc5ec
authored
Sep 15, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
6b8ebcd1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
24 deletions
+78
-24
software/seleniumrunner/test/setup.py
software/seleniumrunner/test/setup.py
+2
-1
software/seleniumrunner/test/test.py
software/seleniumrunner/test/test.py
+76
-23
No files found.
software/seleniumrunner/test/setup.py
View file @
dedbc5ec
...
...
@@ -46,7 +46,8 @@ setup(name=name,
'erp5.util'
,
'selenium'
,
'psutil'
,
'image'
'image'
,
'requests'
,
],
zip_safe
=
True
,
test_suite
=
'test'
,
...
...
software/seleniumrunner/test/test.py
View file @
dedbc5ec
...
...
@@ -43,6 +43,7 @@ from selenium.webdriver.support import expected_conditions as EC
from
PIL
import
Image
from
io
import
BytesIO
import
requests
from
utils
import
SlapOSInstanceTestCase
from
utils
import
findFreeTCPPort
...
...
@@ -121,11 +122,11 @@ class BrowserCompatibilityMixin(WebServerMixin):
def
setUp
(
self
):
super
(
BrowserCompatibilityMixin
,
self
).
setUp
()
self
.
driver
=
webdriver
.
Remote
(
command_executor
=
self
.
computer_partition
.
getConnectionParameterDict
()[
'url'
],
command_executor
=
self
.
computer_partition
.
getConnectionParameterDict
()[
'
backend-
url'
],
desired_capabilities
=
self
.
desired_capabilities
)
def
tearDown
(
self
):
self
.
driver
.
close
()
self
.
driver
.
quit
()
super
(
BrowserCompatibilityMixin
,
self
).
tearDown
()
def
test_user_agent
(
self
):
...
...
@@ -150,20 +151,26 @@ class BrowserCompatibilityMixin(WebServerMixin):
def
test_window_and_screen_size
(
self
):
size
=
json
.
loads
(
self
.
driver
.
execute_script
(
'''
return JSON.stringify({
'screen.
availWidth': window.screen.availW
idth,
'screen.
availHeight': window.screen.availH
eight,
'screen.
width': window.screen.w
idth,
'screen.
height': window.screen.h
eight,
'screen.pixelDepth': window.screen.pixelDepth,
'innerWidth': window.innerWidth,
'innerHeight': window.innerHeight })'''
))
# Xvfb is configured like this
self
.
assertEqual
(
1024
,
size
[
'screen.
availW
idth'
])
self
.
assertEqual
(
768
,
size
[
'screen.
availH
eight'
])
self
.
assertEqual
(
1024
,
size
[
'screen.
w
idth'
])
self
.
assertEqual
(
768
,
size
[
'screen.
h
eight'
])
self
.
assertEqual
(
24
,
size
[
'screen.pixelDepth'
])
# window size must not be 0 (wrong firefox integration report this)
self
.
assertGreater
(
size
[
'innerWidth'
],
0
)
self
.
assertGreater
(
size
[
'innerHeight'
],
0
)
#def test_resize_window(self):
# self.fail('TODO')
#def test_upload_file(self):
# self.fail('TODO')
class
SeleniumServerTestCase
(
SlapOSInstanceTestCase
):
"""Test the remote driver on a minimal web server.
...
...
@@ -173,10 +180,10 @@ class SeleniumServerTestCase(SlapOSInstanceTestCase):
return
(
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'software.cfg'
)),
)
class
TestBrowserSelection
(
SeleniumServerTestCase
,
WebServerMixin
):
class
TestBrowserSelection
(
WebServerMixin
,
SeleniumServerTestCase
):
def
test_firefox
(
self
):
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
webdriver_url
=
parameter_dict
[
'url'
]
webdriver_url
=
parameter_dict
[
'
backend-
url'
]
driver
=
webdriver
.
Remote
(
command_executor
=
webdriver_url
,
...
...
@@ -192,7 +199,7 @@ class TestBrowserSelection(SeleniumServerTestCase, WebServerMixin):
def
test_chrome
(
self
):
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
webdriver_url
=
parameter_dict
[
'url'
]
webdriver_url
=
parameter_dict
[
'
backend-
url'
]
driver
=
webdriver
.
Remote
(
command_executor
=
webdriver_url
,
...
...
@@ -209,9 +216,9 @@ class TestBrowserSelection(SeleniumServerTestCase, WebServerMixin):
driver
.
execute_script
(
'return navigator.userAgent'
))
driver
.
quit
()
def
test_firefox_desired_version
(
self
):
def
XXX_
test_firefox_desired_version
(
self
):
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
webdriver_url
=
parameter_dict
[
'url'
]
webdriver_url
=
parameter_dict
[
'
backend-
url'
]
desired_capabilities
=
DesiredCapabilities
.
FIREFOX
.
copy
()
desired_capabilities
[
'version'
]
=
'51.0.1'
...
...
@@ -234,20 +241,19 @@ class TestBrowserSelection(SeleniumServerTestCase, WebServerMixin):
def
test_parralel_connections
(
self
):
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
webdriver_url
=
parameter_dict
[
'url'
]
return
webdriver_url
=
parameter_dict
[
'backend-url'
]
queue
=
multiprocessing
.
Queue
()
def
_test
(
q
,
server_url
):
driver
=
webdriver
.
Remote
(
command_executor
=
webdriver_url
,
desired_capabilities
=
DesiredCapabilities
.
FIREFOX
)
# XXX we need to sleep a bit to wait for browser to be ready before using it, otherwise selenium crash
sleep
(
2
)
driver
.
get
(
server_url
)
q
.
put
(
driver
.
title
==
'Test page'
)
driver
.
quit
()
# XXX
desired_capabilities
=
dict
(
DesiredCapabilities
.
FIREFOX
,
version
=
'52.9.0esr'
))
#DesiredCapabilities.FIREFOX)
try
:
driver
.
get
(
server_url
)
q
.
put
(
driver
.
title
==
'Test page'
)
finally
:
driver
.
quit
()
nb_workers
=
10
workers
=
[]
...
...
@@ -266,6 +272,48 @@ class TestBrowserSelection(SeleniumServerTestCase, WebServerMixin):
[
queue
.
get
()
for
_
in
range
(
nb_workers
)])
class
TestFrontend
(
WebServerMixin
,
SeleniumServerTestCase
):
def
test_register_url
(
self
):
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
register_url
=
parameter_dict
[
'register-url'
]
parsed
=
urlparse
.
urlparse
(
register_url
)
self
.
assertEqual
(
'node'
,
parsed
.
username
)
self
.
assertTrue
(
parsed
.
password
)
self
.
assertIn
(
# we don't do a proper register request, this response is 500.
'JsonException: Expected to read a START_MAP but instead have: END'
,
requests
.
get
(
register_url
,
verify
=
False
).
text
)
def
test_admin
(
self
):
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
admin_url
=
parameter_dict
[
'admin-url'
]
parsed
=
urlparse
.
urlparse
(
admin_url
)
self
.
assertEqual
(
'admin'
,
parsed
.
username
)
self
.
assertTrue
(
parsed
.
password
)
self
.
assertIn
(
'Grid Console'
,
requests
.
get
(
admin_url
,
verify
=
False
).
text
)
def
test_browser_use_hub
(
self
):
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
webdriver_url
=
parameter_dict
[
'url'
]
parsed
=
urlparse
.
urlparse
(
webdriver_url
)
self
.
assertEqual
(
'selenium'
,
parsed
.
username
)
self
.
assertTrue
(
parsed
.
password
)
driver
=
webdriver
.
Remote
(
command_executor
=
webdriver_url
,
desired_capabilities
=
DesiredCapabilities
.
CHROME
)
driver
.
get
(
self
.
server_url
)
self
.
assertEqual
(
'Test page'
,
driver
.
title
)
driver
.
quit
()
class
TestFirefox52
(
BrowserCompatibilityMixin
,
SeleniumServerTestCase
):
desired_capabilities
=
dict
(
DesiredCapabilities
.
FIREFOX
,
version
=
'52.9.0esr'
)
user_agent
=
'Gecko/20100101 Firefox/52.0'
...
...
@@ -281,9 +329,14 @@ class TestChrome69(BrowserCompatibilityMixin, SeleniumServerTestCase):
user_agent
=
'Chrome/69.0.3497.0'
#del TestFirefox52
del
TestFirefox60
del
TestBrowserSelection
if
1
:
del
TestFrontend
del
TestChrome69
del
TestFirefox52
#del TestFirefox60
del
TestBrowserSelection
# more test:
# XXX run ERP5 test !
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