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,27 +188,70 @@ class FunctionalTestRunner: ...@@ -185,27 +188,70 @@ class FunctionalTestRunner:
) )
def test(self, debug=0): def test(self, debug=0):
xvfb = Xvfb(self.instance_home)
try: try:
if not (debug and os.getenv('DISPLAY')): xvfb = browser = None
print("\nSet 'erp5_debug_mode' environment variable to 1" if 0:
" to use your existing display instead of Xvfb.") if not (debug and os.getenv('DISPLAY')):
xvfb.run() xvfb = Xvfb(self.instance_home)
capabilities = webdriver.common.desired_capabilities \ print("\nSet 'erp5_debug_mode' environment variable to 1"
.DesiredCapabilities.FIREFOX.copy() " to use your existing display instead of Xvfb.")
capabilities['marionette'] = True xvfb.run()
# Zope is accessed through apache with a certificate not trusted by firefox capabilities = webdriver.common.desired_capabilities \
capabilities['acceptInsecureCerts'] = True .DesiredCapabilities.FIREFOX.copy()
# Service workers are disabled on Firefox 52 ESR: capabilities['marionette'] = True
# https://bugzilla.mozilla.org/show_bug.cgi?id=1338144 # Zope is accessed through apache with a certificate not trusted by firefox
options = webdriver.FirefoxOptions() capabilities['acceptInsecureCerts'] = True
options.set_preference('dom.serviceWorkers.enabled', True)
kw = dict(capabilities=capabilities, options=options) # Service workers are disabled on Firefox 52 ESR:
firefox_bin = os.environ.get('firefox_bin') # https://bugzilla.mozilla.org/show_bug.cgi?id=1338144
if firefox_bin: options = webdriver.FirefoxOptions()
geckodriver = os.path.join(os.path.dirname(firefox_bin), 'geckodriver') options.set_preference('dom.serviceWorkers.enabled', True)
kw.update(firefox_binary=firefox_bin, executable_path=geckodriver) kw = dict(capabilities=capabilities, options=options)
browser = webdriver.Firefox(**kw) firefox_bin = os.environ.get('firefox_bin')
if firefox_bin:
geckodriver = os.path.join(os.path.dirname(firefox_bin), 'geckodriver')
kw.update(firefox_binary=firefox_bin, executable_path=geckodriver)
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,9 +290,11 @@ class FunctionalTestRunner: ...@@ -244,9 +290,11 @@ class FunctionalTestRunner:
).encode('UTF-8'), ).encode('UTF-8'),
html_parser html_parser
) )
browser.quit()
finally: finally:
xvfb.quit() if browser:
browser.quit()
if xvfb:
xvfb.quit()
return iframe return iframe
def processResult(self, iframe): def processResult(self, 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