Commit 24c8a246 authored by Duggan, John's avatar Duggan, John
Browse files

Change the approach to detecting visibility of the progress bar

parent 7ec8b353
Loading
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -2,21 +2,26 @@

from selenium.webdriver import ActionChains, Firefox
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait


def test_tool_components(driver: Firefox) -> None:
    wait = WebDriverWait(driver, timeout=10)
    run_button = driver.find_element(By.ID, "execution_test_run")
    cancel_button = driver.find_element(By.ID, "execution_test_cancel")
    progress_bar_running = driver.find_element(By.ID, "progress_bar_test_show_progress")
    progress_bar_finished = driver.find_element(By.ID, "progress_bar_test_show_ok")
    outputs = driver.find_element(By.ID, "tool_outputs_test_outputs")
    errors = driver.find_element(By.ID, "tool_outputs_test_errors")

    ActionChains(driver).click(run_button).perform()
    ActionChains(driver).click(run_button).pause(2).perform()
    # The progress bar should be visible and the output textareas should have content.
    wait.until(expected_conditions.visibility_of_element_located((By.ID, "progress_bar_test_show_progress")))
    assert driver.find_element(By.ID, "tool_outputs_test_outputs").get_attribute("value") == "test_output"
    assert driver.find_element(By.ID, "tool_outputs_test_errors").get_attribute("value") == "test_error"
    running_style = progress_bar_running.get_attribute("style")
    assert running_style and "display: none;" not in running_style
    assert outputs.get_attribute("value") == "test_output"
    assert errors.get_attribute("value") == "test_error"

    ActionChains(driver).click(cancel_button).perform()
    ActionChains(driver).click(cancel_button).pause(2).perform()
    # The finished bar should be visible.
    wait.until(expected_conditions.visibility_of_element_located((By.ID, "progress_bar_test_show_ok")))
    running_style = progress_bar_running.get_attribute("style")
    assert running_style and "display: none;" in running_style
    finished_style = progress_bar_finished.get_attribute("style")
    assert finished_style and "display: none;" not in finished_style