mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-07-07 23:50:55 +00:00
Merge pull request #45 from downtownallday/selenium4
Upgrade to Selenium 4
This commit is contained in:
commit
94b7a04615
@ -138,6 +138,7 @@ installed_state_compare() {
|
|||||||
RELEASE_A="${RELEASE:-0}"
|
RELEASE_A="${RELEASE:-0}"
|
||||||
PROD_A="miab"
|
PROD_A="miab"
|
||||||
grep "mailinabox-ldap" <<<"$GIT_ORIGIN" >/dev/null && PROD_A="miabldap"
|
grep "mailinabox-ldap" <<<"$GIT_ORIGIN" >/dev/null && PROD_A="miabldap"
|
||||||
|
MIGRATION_VERSION_A="${MIGRATION_VERSION:-0}"
|
||||||
MIGRATION_ML_VERSION_A="${MIGRATION_ML_VERSION:-0}"
|
MIGRATION_ML_VERSION_A="${MIGRATION_ML_VERSION:-0}"
|
||||||
|
|
||||||
source "$s2/info.txt"
|
source "$s2/info.txt"
|
||||||
@ -146,6 +147,7 @@ installed_state_compare() {
|
|||||||
RELEASE_B="${RELEASE:-0}"
|
RELEASE_B="${RELEASE:-0}"
|
||||||
PROD_B="miab"
|
PROD_B="miab"
|
||||||
grep "mailinabox-ldap" <<<"$GIT_ORIGIN" >/dev/null && PROD_B="miabldap"
|
grep "mailinabox-ldap" <<<"$GIT_ORIGIN" >/dev/null && PROD_B="miabldap"
|
||||||
|
MIGRATION_VERSION_B="${MIGRATION_VERSION:-0}"
|
||||||
MIGRATION_ML_VERSION_B="${MIGRATION_ML_VERSION:-0}"
|
MIGRATION_ML_VERSION_B="${MIGRATION_ML_VERSION:-0}"
|
||||||
|
|
||||||
cmptype="${PROD_A}2${PROD_B}"
|
cmptype="${PROD_A}2${PROD_B}"
|
||||||
@ -178,13 +180,16 @@ installed_state_compare() {
|
|||||||
|
|
||||||
# s2: re-sort aliases
|
# s2: re-sort aliases
|
||||||
jq -c ".[] | .aliases | sort_by(.address) | .[] | {address:.address, forwards_to:.forwards_to, permitted_senders:.permitted_senders, auto:.auto, description:.description}" "$s2/aliases.json" > "$s2/aliases-cmp.json"
|
jq -c ".[] | .aliases | sort_by(.address) | .[] | {address:.address, forwards_to:.forwards_to, permitted_senders:.permitted_senders, auto:.auto, description:.description}" "$s2/aliases.json" > "$s2/aliases-cmp.json"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $MIGRATION_ML_VERSION_A -le 2 -a $MIGRATION_ML_VERSION_B -ge 3 ]; then
|
# before quota support to one with it
|
||||||
# miabldap migration level <=2 does not have quota fields, so
|
if [ "$cmptype" = "miabldap2miabldap" -a $MIGRATION_ML_VERSION_A -le 2 -a $MIGRATION_ML_VERSION_B -ge 3
|
||||||
# remove them from the comparison
|
-o "$cmdtype" = "miab2miabldap" -a $MIGRATION_VERSION_A -lt 15 -a $MIGRATION_ML_VERSION_B -ge 3 ]; then
|
||||||
grep -vE '"(quota|box_quota|box_size|percent)":' "$s2/users-cmp.json" > "$s2/users-cmp2.json" || changed="true"
|
# miabldap migration level <=2 does not have quota fields
|
||||||
cp "$s2/users-cmp2.json" "$s2/users-cmp.json" && rm -f "$s2/users-cmp2.json"
|
# miab migration level <15 does not have quota fields
|
||||||
fi
|
# ... remove them from the comparison
|
||||||
|
grep -vE '"(quota|box_quota|box_size|percent)":' "$s2/users-cmp.json" > "$s2/users-cmp2.json" || changed="true"
|
||||||
|
cp "$s2/users-cmp2.json" "$s2/users-cmp.json" && rm -f "$s2/users-cmp2.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- indent-tabs-mode: nil; -*-
|
||||||
#####
|
#####
|
||||||
##### This file is part of Mail-in-a-Box-LDAP which is released under the
|
##### This file is part of Mail-in-a-Box-LDAP which is released under the
|
||||||
##### terms of the GNU Affero General Public License as published by the
|
##### terms of the GNU Affero General Public License as published by the
|
||||||
@ -22,7 +23,7 @@ from selenium.common.exceptions import (
|
|||||||
ElementNotInteractableException
|
ElementNotInteractableException
|
||||||
)
|
)
|
||||||
|
|
||||||
import os
|
import os, sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -59,7 +60,10 @@ class ChromeTestDriver(Chrome):
|
|||||||
'''
|
'''
|
||||||
if not options:
|
if not options:
|
||||||
options = ChromeOptions()
|
options = ChromeOptions()
|
||||||
options.headless = True
|
options.headless = True # old method going away...
|
||||||
|
options.add_argument("--headless=new")
|
||||||
|
|
||||||
|
# options.binary_location = '/snap/bin/chromium'
|
||||||
|
|
||||||
# set a window size
|
# set a window size
|
||||||
options.add_argument("--window-size=1200x600")
|
options.add_argument("--window-size=1200x600")
|
||||||
@ -72,9 +76,25 @@ class ChromeTestDriver(Chrome):
|
|||||||
# required to run chromium as root
|
# required to run chromium as root
|
||||||
options.add_argument('--no-sandbox')
|
options.add_argument('--no-sandbox')
|
||||||
|
|
||||||
super(ChromeTestDriver, self).__init__(
|
# optional: set what profile directory to use
|
||||||
|
# ... parent directory must exist
|
||||||
|
# options.add_argument(
|
||||||
|
# f'--user-data-dir={os.environ["HOME"]}/.config/chromium'
|
||||||
|
# )
|
||||||
|
|
||||||
|
from selenium.webdriver.chrome.service import Service as ChromeService
|
||||||
|
service = ChromeService(
|
||||||
executable_path='/snap/bin/chromium.chromedriver',
|
executable_path='/snap/bin/chromium.chromedriver',
|
||||||
options=options
|
# these logging options don't seem to do anything
|
||||||
|
# service_args=[
|
||||||
|
# '--log-level=ALL', # ALL, DEBUG, INFO, WARNING, SEVERE, OFF
|
||||||
|
# '--enable-chrome-logs',
|
||||||
|
# ]
|
||||||
|
)
|
||||||
|
|
||||||
|
super(ChromeTestDriver, self).__init__(
|
||||||
|
service=service,
|
||||||
|
options=options,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.delete_all_cookies()
|
self.delete_all_cookies()
|
||||||
@ -87,8 +107,13 @@ class FirefoxTestDriver(Firefox):
|
|||||||
options = FirefoxOptions()
|
options = FirefoxOptions()
|
||||||
options.headless = True
|
options.headless = True
|
||||||
|
|
||||||
|
from selenium.webdriver.firefox.service import Service as FirefoxService
|
||||||
|
service = FirefoxService(
|
||||||
|
executable_path='/usr/local/bin/geckodriver'
|
||||||
|
)
|
||||||
|
|
||||||
super(FirefoxTestDriver, self).__init__(
|
super(FirefoxTestDriver, self).__init__(
|
||||||
executable_path='/usr/local/bin/geckodriver',
|
service=service,
|
||||||
options=options
|
options=options
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -469,19 +494,21 @@ class ElWrapper(object):
|
|||||||
return self.el.get_attribute(name)
|
return self.el.get_attribute(name)
|
||||||
|
|
||||||
def get_property(self, expr):
|
def get_property(self, expr):
|
||||||
self.driver.say_verbose('get property %s', expr)
|
|
||||||
prefix = '.'
|
prefix = '.'
|
||||||
if expr.startswith('.') or expr.startswith('['): prefix=''
|
if expr.startswith('.') or expr.startswith('['): prefix=''
|
||||||
|
self.driver.say_verbose(f'get property {self.el.tag_name}{prefix}{expr}')
|
||||||
|
args=[self.el]
|
||||||
p = self.driver.execute_script(
|
p = self.driver.execute_script(
|
||||||
"return arguments[0]%s%s;" % ( prefix, expr ),
|
f'return arguments[0]{prefix}{expr};',
|
||||||
self.el
|
True,
|
||||||
|
*args
|
||||||
)
|
)
|
||||||
if isinstance(p, WebElement):
|
if isinstance(p, WebElement):
|
||||||
p = ElWrapper(self.driver, p)
|
p = ElWrapper(self.driver, p)
|
||||||
if isinstance(p, bool):
|
if isinstance(p, bool) or isinstance(p, int) or ( isinstance(p, str) and len(p) < 100 ):
|
||||||
self.driver.say_verbose('property result: %s', p)
|
self.driver.say_verbose('property value: %s', p)
|
||||||
else:
|
else:
|
||||||
self.driver.say_verbose('property result: %s', p.__class__)
|
self.driver.say_verbose('property type: %s', p.__class__)
|
||||||
return p
|
return p
|
||||||
|
|
||||||
def content(self, max_length=None, ellipses=True):
|
def content(self, max_length=None, ellipses=True):
|
||||||
@ -504,9 +531,11 @@ class ElWrapper(object):
|
|||||||
|
|
||||||
def parent(self):
|
def parent(self):
|
||||||
# get the parent element
|
# get the parent element
|
||||||
|
args=[self.el]
|
||||||
p = self.driver.execute_script(
|
p = self.driver.execute_script(
|
||||||
"return arguments[0].parentNode;",
|
"return arguments[0].parentNode;",
|
||||||
self.el
|
True,
|
||||||
|
*args
|
||||||
)
|
)
|
||||||
return ElWrapper(self.driver, p)
|
return ElWrapper(self.driver, p)
|
||||||
|
|
||||||
@ -546,4 +575,3 @@ class ElWrapper(object):
|
|||||||
|
|
||||||
#dir(driver)
|
#dir(driver)
|
||||||
#['__abstractmethods__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_abc_impl', '_authenticator_id', '_file_detector', '_get_cdp_details', '_is_remote', '_mobile', '_shadowroot_cls', '_switch_to', '_unwrap_value', '_web_element_cls', '_wrap_value', 'add_cookie', 'add_credential', 'add_virtual_authenticator', 'application_cache', 'back', 'bidi_connection', 'capabilities', 'caps', 'close', 'command_executor', 'create_options', 'create_web_element', 'current_url', 'current_window_handle', 'delete_all_cookies', 'delete_cookie', 'delete_network_conditions', 'desired_capabilities', 'error_handler', 'execute', 'execute_async_script', 'execute_cdp_cmd', 'execute_script', 'file_detector', 'file_detector_context', 'find_element', 'find_elements', 'forward', 'fullscreen_window', 'get', 'get_cookie', 'get_cookies', 'get_credentials', 'get_issue_message', 'get_log', 'get_network_conditions', 'get_pinned_scripts', 'get_screenshot_as_base64', 'get_screenshot_as_file', 'get_screenshot_as_png', 'get_sinks', 'get_window_position', 'get_window_rect', 'get_window_size', 'implicitly_wait', 'launch_app', 'log_types', 'maximize_window', 'minimize_window', 'mobile', 'name', 'orientation', 'page_source', 'pin_script', 'pinned_scripts', 'port', 'print_page', 'quit', 'refresh', 'remove_all_credentials', 'remove_credential', 'remove_virtual_authenticator', 'save_screenshot', 'service', 'session_id', 'set_network_conditions', 'set_page_load_timeout', 'set_permissions', 'set_script_timeout', 'set_sink_to_use', 'set_user_verified', 'set_window_position', 'set_window_rect', 'set_window_size', 'start_client', 'start_desktop_mirroring', 'start_session', 'start_tab_mirroring', 'stop_casting', 'stop_client', 'switch_to', 'timeouts', 'title', 'unpin', 'vendor_prefix', 'virtual_authenticator_id', 'window_handles']
|
#['__abstractmethods__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_abc_impl', '_authenticator_id', '_file_detector', '_get_cdp_details', '_is_remote', '_mobile', '_shadowroot_cls', '_switch_to', '_unwrap_value', '_web_element_cls', '_wrap_value', 'add_cookie', 'add_credential', 'add_virtual_authenticator', 'application_cache', 'back', 'bidi_connection', 'capabilities', 'caps', 'close', 'command_executor', 'create_options', 'create_web_element', 'current_url', 'current_window_handle', 'delete_all_cookies', 'delete_cookie', 'delete_network_conditions', 'desired_capabilities', 'error_handler', 'execute', 'execute_async_script', 'execute_cdp_cmd', 'execute_script', 'file_detector', 'file_detector_context', 'find_element', 'find_elements', 'forward', 'fullscreen_window', 'get', 'get_cookie', 'get_cookies', 'get_credentials', 'get_issue_message', 'get_log', 'get_network_conditions', 'get_pinned_scripts', 'get_screenshot_as_base64', 'get_screenshot_as_file', 'get_screenshot_as_png', 'get_sinks', 'get_window_position', 'get_window_rect', 'get_window_size', 'implicitly_wait', 'launch_app', 'log_types', 'maximize_window', 'minimize_window', 'mobile', 'name', 'orientation', 'page_source', 'pin_script', 'pinned_scripts', 'port', 'print_page', 'quit', 'refresh', 'remove_all_credentials', 'remove_credential', 'remove_virtual_authenticator', 'save_screenshot', 'service', 'session_id', 'set_network_conditions', 'set_page_load_timeout', 'set_permissions', 'set_script_timeout', 'set_sink_to_use', 'set_user_verified', 'set_window_position', 'set_window_rect', 'set_window_size', 'start_client', 'start_desktop_mirroring', 'start_session', 'start_tab_mirroring', 'stop_casting', 'stop_client', 'switch_to', 'timeouts', 'title', 'unpin', 'vendor_prefix', 'virtual_authenticator_id', 'window_handles']
|
||||||
|
|
||||||
|
@ -166,8 +166,7 @@ init_miab_testing() {
|
|||||||
echo "Install chromium, selenium"
|
echo "Install chromium, selenium"
|
||||||
exec_no_output snap install chromium \
|
exec_no_output snap install chromium \
|
||||||
|| die "Unable to install chromium!"
|
|| die "Unable to install chromium!"
|
||||||
# TODO: selenium 4 (has breaking changes). See: https://www.selenium.dev/documentation/webdriver/getting_started/upgrade_to_selenium_4/
|
exec_no_output python3 -m pip install "selenium>=4.4" --quiet \
|
||||||
exec_no_output python3 -m pip install "selenium>=3,<4" --quiet \
|
|
||||||
|| die "Selenium install failed!"
|
|| die "Selenium install failed!"
|
||||||
|
|
||||||
# tell git our directory is safe (new requirement for git 2.35.2)
|
# tell git our directory is safe (new requirement for git 2.35.2)
|
||||||
|
Loading…
Reference in New Issue
Block a user