Commit 54ca6494 authored by Jérome Perrin's avatar Jérome Perrin

wip: run test with selenium server

parent c8036d39
...@@ -45,6 +45,7 @@ from selenium import webdriver ...@@ -45,6 +45,7 @@ from selenium import webdriver
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.remote.remote_connection import RemoteConnection
# selenium workaround for localhost / 127.0.0.1 resolution # selenium workaround for localhost / 127.0.0.1 resolution
# ------ # ------
...@@ -172,6 +173,8 @@ class FunctionalTestRunner: ...@@ -172,6 +173,8 @@ class FunctionalTestRunner:
return self.portal.portal_tests.TestTool_getResults(self.run_only) return self.portal.portal_tests.TestTool_getResults(self.run_only)
def _getTestBaseURL(self): def _getTestBaseURL(self):
return 'https://[2001:67c:1254:26::5e5f]:8445/erp5/'
# Access the https proxy in front of runUnitTest's zserver # Access the https proxy in front of runUnitTest's zserver
base_url = os.getenv('zserver_frontend_url') base_url = os.getenv('zserver_frontend_url')
if base_url: if base_url:
...@@ -185,9 +188,11 @@ class FunctionalTestRunner: ...@@ -185,9 +188,11 @@ class FunctionalTestRunner:
) )
def test(self, debug=0): def test(self, debug=0):
xvfb = Xvfb(self.instance_home)
try: try:
xvfb = browser = None
if 0:
if not (debug and os.getenv('DISPLAY')): if not (debug and os.getenv('DISPLAY')):
xvfb = Xvfb(self.instance_home)
print("\nSet 'erp5_debug_mode' environment variable to 1" print("\nSet 'erp5_debug_mode' environment variable to 1"
" to use your existing display instead of Xvfb.") " to use your existing display instead of Xvfb.")
xvfb.run() xvfb.run()
...@@ -196,6 +201,7 @@ class FunctionalTestRunner: ...@@ -196,6 +201,7 @@ class FunctionalTestRunner:
capabilities['marionette'] = True capabilities['marionette'] = True
# Zope is accessed through apache with a certificate not trusted by firefox # Zope is accessed through apache with a certificate not trusted by firefox
capabilities['acceptInsecureCerts'] = True capabilities['acceptInsecureCerts'] = True
# Service workers are disabled on Firefox 52 ESR: # Service workers are disabled on Firefox 52 ESR:
# https://bugzilla.mozilla.org/show_bug.cgi?id=1338144 # https://bugzilla.mozilla.org/show_bug.cgi?id=1338144
options = webdriver.FirefoxOptions() options = webdriver.FirefoxOptions()
...@@ -206,6 +212,46 @@ class FunctionalTestRunner: ...@@ -206,6 +212,46 @@ class FunctionalTestRunner:
geckodriver = os.path.join(os.path.dirname(firefox_bin), 'geckodriver') geckodriver = os.path.join(os.path.dirname(firefox_bin), 'geckodriver')
kw.update(firefox_binary=firefox_bin, executable_path=geckodriver) kw.update(firefox_binary=firefox_bin, executable_path=geckodriver)
browser = webdriver.Firefox(**kw) browser = webdriver.Firefox(**kw)
else:
# workaround for https://github.com/SeleniumHQ/selenium/issues/6534
# TODO: version up selenium
if 0:
executor = RemoteConnection(
'https://selenium:jefmnwhzsral@[2001:67c:1254:26::40e6]:9443/wd/hub',
keep_alive=True)
import urllib3
executor._conn = urllib3.PoolManager(cert_reqs='CERT_NONE', ca_certs=None)
else:
executor = 'http://10.0.128.126:4444/wd/hub'
browser = webdriver.Remote(
command_executor=executor,
desired_capabilities={
'browserName': 'firefox', # or chrome
#'version': '52.9.0esr',
#'version': '68.0.2esr',
'acceptInsecureCerts': True,
})
# browser.set_window_size()
"""
Editor Delete Cell
Maximize Gadget Editor
Sort in the Editor
Sum Column Updated
Editing Sum Column Updates all Cells ( precision 2 )
"""
"""
Editor Copy and Paste
Adding a New Line
Editor Copy and Paste Using , as Decimal Separator
Editor Delete Cell
Editor Refuses Duplicate Cell Coordinates
Editor Refuses Unknown Dimensions
Maximize Gadget Editor
Sort in the Editor
Sum Column Updated
"""
start_time = time.time() start_time = time.time()
browser.get(self._getTestBaseURL() + '/login_form') browser.get(self._getTestBaseURL() + '/login_form')
login_field = WebDriverWait(browser, 10).until( login_field = WebDriverWait(browser, 10).until(
...@@ -244,8 +290,10 @@ class FunctionalTestRunner: ...@@ -244,8 +290,10 @@ class FunctionalTestRunner:
).encode('UTF-8'), ).encode('UTF-8'),
html_parser html_parser
) )
browser.quit()
finally: finally:
if browser:
browser.quit()
if xvfb:
xvfb.quit() xvfb.quit()
return iframe return iframe
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment