Skip to content

Commit

Permalink
Merge pull request #1253 from indridieinarsson/fix_folder_test
Browse files Browse the repository at this point in the history
Fix reload_folder_list browser test
  • Loading branch information
Shadow243 authored Sep 27, 2024
2 parents 224e503 + 5a3e849 commit a31aad7
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/selenium/folder_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
from base import WebTest, USER, PASS
from selenium.webdriver.common.by import By
from runner import test_runner
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import StaleElementReferenceException

class FolderListTests(WebTest):

Expand All @@ -12,10 +16,20 @@ def __init__(self):
self.wait_with_folder_list()

def reload_folder_list(self):
assert self.by_class('main_menu').text.startswith('Main')
main_menu = self.by_class('main_menu')
assert main_menu.text.startswith('Main')
self.by_class('update_message_list').click()
self.safari_workaround(3)
assert self.by_class('main_menu').text.startswith('Main')
# update_message_list triggers site reload, so we explicitly wait for element to become stale
WebDriverWait(self.driver, 20).until(EC.staleness_of(main_menu))
ignored_exceptions=(NoSuchElementException,StaleElementReferenceException,)
# And once it is stale, we can now wait for it to become available again as the page contents are loaded again.
main_menu = WebDriverWait(self.driver, 10,ignored_exceptions=ignored_exceptions).until(
EC.presence_of_element_located((By.CLASS_NAME, 'main_menu'))
)
main_menu = self.by_class('main_menu')
#and finally perform our test on the actual, refreshed element.
assert main_menu.text.startswith('Main')

def expand_section(self):
self.by_css('[data-source=".settings"]').click()
Expand Down Expand Up @@ -59,7 +73,7 @@ def show_folders(self):

print("FOLDER LIST TESTS")
test_runner(FolderListTests, [
# 'reload_folder_list',
'reload_folder_list',
'expand_section',
'collapse_section',
'hide_folders',
Expand Down

0 comments on commit a31aad7

Please sign in to comment.