Commit 94ba5553 authored by Stephane Glondu's avatar Stephane Glondu

Merge branch 'swergas'

parents 23f823e8 79153535
Pipeline #59841 passed with stages
in 16 minutes and 38 seconds
......@@ -48,8 +48,8 @@ let basic_check_private_key s =
if i < n then
match s.[i] with
| '"' -> middle (i+1)
| _ -> failwith "Must start with a double quote"
else failwith "Too short"
| _ -> failwith "Must start with a double quote (character given was another character)"
else failwith "Must start with a double quote (empty string given)"
and middle i =
if i < n then
match s.[i] with
......
......@@ -2012,7 +2012,9 @@ let election_admin election metadata state get_tokens_decrypt () =
[pcdata "encrypted tally"]
(uuid, ESETally);
pcdata " has been computed. Its hash is ";
b [pcdata hash];
b ~a:[a_id "encrypted_tally_hash"] [
pcdata hash
];
pcdata ".";
];
div [
......
#!/usr/bin/python
# -*- coding: utf-8 -*
# coding: utf-8
from os.path import abspath, dirname
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#!/usr/bin/python
# -*- coding: utf-8 -*
# coding: utf-8
import re
import subprocess
......
#!/usr/bin/python
# -*- coding: utf-8 -*
# coding: utf-8
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
......@@ -10,32 +10,50 @@ from selenium.common.exceptions import StaleElementReferenceException
DEFAULT_WAIT_DURATION = 10 # In seconds
class element_has_non_empty_content(object):
class element_has_non_empty_attribute(object):
"""
An expectation for checking that an element has a non-empty innerText attribute.
An expectation for checking that an element has a non-empty value for given attribute.
This class is meant to be used in combination with Selenium's `WebDriverWait::until()`. For example:
```
custom_wait = WebDriverWait(browser, 10)
smart_ballot_tracker_element = custom_wait.until(element_has_non_empty_content((By.ID, "my_id")))
smart_ballot_tracker_element = custom_wait.until(element_has_non_empty_attribute((By.ID, "my_id"), 'value'))
```
:param locator: Selenium locator used to find the element. For example: `(By.ID, "my_id")`
:param attribute: HTML attribute. For example 'innerText' (see `element_has_non_empty_content()` for this), or 'value'
:return: The WebElement once it has a non-empty innerText attribute
"""
def __init__(self, locator):
def __init__(self, locator, attribute):
self.locator = locator
self.attribute = attribute
def __call__(self, driver):
element = driver.find_element(*self.locator) # Finding the referenced element
if not element:
return False
element_content = element.get_attribute('innerText').strip()
element_content = element.get_attribute(self.attribute).strip()
if len(element_content) > 0:
return element
else:
return False
class element_has_non_empty_content(element_has_non_empty_attribute):
"""
An expectation for checking that an element has a non-empty innerText attribute.
This class is meant to be used in combination with Selenium's `WebDriverWait::until()`. For example:
```
custom_wait = WebDriverWait(browser, 10)
smart_ballot_tracker_element = custom_wait.until(element_has_non_empty_content((By.ID, "my_id")))
```
:param locator: Selenium locator used to find the element. For example: `(By.ID, "my_id")`
:return: The WebElement once it has a non-empty innerText attribute
"""
def __init__(self, locator):
super().__init__(locator, 'innerText')
class an_element_with_partial_link_text_exists(object):
def __init__(self, partial_link_text):
self.partial_link_text = partial_link_text
......@@ -93,14 +111,18 @@ def wait_for_element_exists_and_contains_expected_text(browser, css_selector, ex
raise Exception("Could not find expected DOM element '" + css_selector + "' with text content '" + expected_text + "' until timeout of " + str(wait_duration) + " seconds. Page source was: " + str(browser.page_source.encode("utf-8"))) from e
def wait_for_element_exists_and_has_non_empty_content(browser, css_selector, wait_duration=DEFAULT_WAIT_DURATION):
def wait_for_element_exists_and_has_non_empty_attribute(browser, css_selector, attribute, wait_duration=DEFAULT_WAIT_DURATION):
try:
ignored_exceptions = (NoSuchElementException, StaleElementReferenceException,)
custom_wait = WebDriverWait(browser, wait_duration, ignored_exceptions=ignored_exceptions)
element = custom_wait.until(element_has_non_empty_content((By.CSS_SELECTOR, css_selector)))
element = custom_wait.until(element_has_non_empty_attribute((By.CSS_SELECTOR, css_selector), attribute))
return element
except Exception as e:
raise Exception("Could not find expected DOM element '" + css_selector + "' with non-empty content until timeout of " + str(wait_duration) + " seconds") from e
raise Exception("Could not find expected DOM element '" + css_selector + "' with non-empty attribute '" + attribute + "' until timeout of " + str(wait_duration) + " seconds") from e
def wait_for_element_exists_and_has_non_empty_content(browser, css_selector, wait_duration=DEFAULT_WAIT_DURATION):
return wait_for_element_exists_and_has_non_empty_attribute(browser, css_selector, 'innerText', wait_duration)
def wait_for_an_element_with_partial_link_text_exists(browser, partial_link_text, wait_duration=DEFAULT_WAIT_DURATION):
......
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