Skip to content

Commit

Permalink
Merge pull request #791 from kroky/bugfix/selenium-tests
Browse files Browse the repository at this point in the history
fix selenium tests to run in different env
  • Loading branch information
kroky authored Oct 11, 2023
2 parents e9cb32c + b0a96ca commit 497d798
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions tests/selenium/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ def __init__(self, cap=None):

def read_ini(self):
self.modules = []
self.auth_type = ''
ini = open(INI_PATH)
for row in ini.readlines():
if re.match('^modules\[\]\=', row):
parts = row.split('=')
self.modules.append(parts[1].strip())
if re.match('^auth_type=', row):
parts = row.split('=')
self.auth_type = row[1]

def load(self):
print(" - loading site")
Expand Down
1 change: 1 addition & 0 deletions tests/selenium/inline_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(self):

def set_inline_message_test(self):
self.checkbox_test('general_setting', 'inline_message', False, 'inline_message')
self.dropdown_test('email_setting', 'all_email_since', '-1 week', '-5 years')

def navigate_msg_test(self):
self.by_css('[data-source=".email_folders"]').click()
Expand Down
2 changes: 2 additions & 0 deletions tests/selenium/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def save(self):
def password(self):
if not self.mod_active('account'):
return
if self.auth_type != 'DB':
return
list_item = self.by_class('menu_change_password')
list_item.find_element_by_tag_name('a').click()
self.wait_with_folder_list()
Expand Down
2 changes: 2 additions & 0 deletions tests/selenium/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from base import WebTest, USER, PASS
from creds import RECIP
from runner import test_runner
from selenium.webdriver.support.ui import Select

class SearchTest(WebTest):

Expand All @@ -19,6 +20,7 @@ def load_search_page(self):
def keyword_search(self):
terms = self.by_id('search_terms')
terms.send_keys('test')
Select(self.by_name('search_since')).select_by_value('-5 years')
self.by_class('search_update').click();
self.wait_with_folder_list()
sleep(1)
Expand Down
12 changes: 10 additions & 2 deletions tests/selenium/send.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from base import WebTest, USER, PASS
from creds import RECIP
from runner import test_runner
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import NoSuchElementException

class SendTest(WebTest):

Expand Down Expand Up @@ -30,14 +32,20 @@ def compose_message(self):
def view_message_list(self):
list_item = self.by_class('menu_unread')
list_item.find_element_by_tag_name('a').click()
self.wait_on_class('unseen')
try:
self.wait_on_class('unseen', 10)
except TimeoutException as e:
return
assert self.by_class('mailbox_list_title').text == 'Unread'
subject = self.by_class('unseen')
link = subject.find_element_by_tag_name('a')
assert link.text == 'Test'

def view_message_detail(self):
subject = self.by_class('unseen')
try:
subject = self.by_class('unseen')
except NoSuchElementException as e:
return
link = subject.find_element_by_tag_name('a').click()
self.wait_on_class('header_subject')
detail_subject = self.by_class('header_subject')
Expand Down
4 changes: 2 additions & 2 deletions tests/selenium/servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def smtp_add(self):
self.by_id('smtp_notls').click()
self.by_name('submit_smtp_server').click()
self.wait_on_sys_message()
assert self.by_class('sys_messages').text == 'Added SMTP server!'
assert self.by_class('sys_messages').text == 'Added SMTP server!' or self.by_class('sys_messages').text == 'Cound not add server: Connection refused'

def smtp_del(self):
self.by_class('delete_smtp_connection').click()
Expand All @@ -52,7 +52,7 @@ def imap_add(self):
self.by_id('imap_notls').click()
self.by_name('submit_imap_server').click()
self.wait_on_sys_message()
assert self.by_class('sys_messages').text == 'Added server!'
assert self.by_class('sys_messages').text == 'Added server!' or self.by_class('sys_messages').text == 'Cound not add server: Connection refused'

def imap_confirm(self):
user = self.by_id('imap_user_'+IMAP_ID)
Expand Down
2 changes: 2 additions & 0 deletions tests/selenium/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def checkbox_test(self, section, name, checked, mod=False):
if mod and not self.mod_active(mod):
return
self.settings_section(section)
if name == 'enable_keyboard_shortcuts':
checked = self.by_name(name).is_selected()
if checked:
self.is_checked(name)
else:
Expand Down

0 comments on commit 497d798

Please sign in to comment.