-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve traitlets type warnings, lint, remove
six
- Loading branch information
1 parent
cf904ba
commit 93e7797
Showing
10 changed files
with
52 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,59 @@ | ||
from functools import partial | ||
|
||
from robot.libraries.BuiltIn import BuiltIn | ||
from robot.utils import timestr_to_secs | ||
from selenium.common.exceptions import NoSuchElementException, TimeoutException | ||
from selenium.webdriver.support.wait import WebDriverWait | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.remote.webdriver import WebDriver | ||
from selenium.webdriver.support.wait import WebDriverWait | ||
from SeleniumLibrary import SeleniumLibrary | ||
|
||
from robot.utils import timestr_to_secs | ||
DIAGNOSTIC_CLASS = "cm-lintRange" | ||
|
||
DIAGNOSTIC_CLASS = 'cm-lintRange' | ||
|
||
def page_contains_diagnostic(driver: WebDriver, selector, negate=False): | ||
elements = driver.find_elements(By.CSS_SELECTOR, f'.{DIAGNOSTIC_CLASS}') | ||
elements = driver.find_elements(By.CSS_SELECTOR, f".{DIAGNOSTIC_CLASS}") | ||
if not elements: | ||
return True if negate else False | ||
driver.execute_script(""" | ||
driver.execute_script( | ||
""" | ||
arguments[0].map(el => { | ||
let diagnostic = el.cmView.mark.spec.diagnostic; | ||
el.title = diagnostic.message + " (" + diagnostic.source + ")"; | ||
}); | ||
""", elements) | ||
""", | ||
elements, | ||
) | ||
try: | ||
driver.find_element(By.CSS_SELECTOR, f'.{DIAGNOSTIC_CLASS}{selector}') | ||
driver.find_element(By.CSS_SELECTOR, f".{DIAGNOSTIC_CLASS}{selector}") | ||
except NoSuchElementException: | ||
return True if negate else False | ||
return False if negate else True | ||
|
||
|
||
def wait_until_page_contains_diagnostic(selector, timeout='5s'): | ||
def wait_until_page_contains_diagnostic(selector, timeout="5s"): | ||
sl: SeleniumLibrary = BuiltIn().get_library_instance("SeleniumLibrary") | ||
wait = WebDriverWait(sl.driver, timestr_to_secs(timeout)) | ||
try: | ||
return wait.until( | ||
partial(page_contains_diagnostic, selector=selector) | ||
) | ||
return wait.until(partial(page_contains_diagnostic, selector=selector)) | ||
except TimeoutException: | ||
elements = sl.driver.find_elements(By.CSS_SELECTOR, f'.{DIAGNOSTIC_CLASS}') | ||
elements = sl.driver.find_elements(By.CSS_SELECTOR, f".{DIAGNOSTIC_CLASS}") | ||
if elements: | ||
titles = ( | ||
'\n - ' | ||
+ '\n - '.join([el.get_attribute('title') for el in elements]) | ||
titles = "\n - " + "\n - ".join( | ||
[el.get_attribute("title") for el in elements] | ||
) | ||
hint = f'Visible diagnostics are: {titles}' | ||
hint = f"Visible diagnostics are: {titles}" | ||
else: | ||
hint = 'No diagnostics were visible.' | ||
hint = "No diagnostics were visible." | ||
raise TimeoutException( | ||
f'Diagnostic with selector {selector} not found in {timeout}.' | ||
f'\n{hint}' | ||
f"Diagnostic with selector {selector} not found in {timeout}." f"\n{hint}" | ||
) | ||
|
||
|
||
def wait_until_page_does_not_contain_diagnostic(selector, timeout='5s'): | ||
def wait_until_page_does_not_contain_diagnostic(selector, timeout="5s"): | ||
sl: SeleniumLibrary = BuiltIn().get_library_instance("SeleniumLibrary") | ||
wait = WebDriverWait(sl.driver, timestr_to_secs(timeout)) | ||
return wait.until( | ||
partial(page_contains_diagnostic, selector=selector, negate=True), | ||
f'Diagnostic with selector {selector} still present after {timeout}' | ||
f"Diagnostic with selector {selector} still present after {timeout}", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ pyls-isort | |
pyls-mypy | ||
pytest-cov | ||
ruamel.yaml | ||
types-six |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,3 @@ dependencies: | |
- pytest-tornasync | ||
- robotframework-robocop | ||
- robotframework-tidy | ||
- types-six |