Skip to content

Commit

Permalink
clean up, and add some keyboard shortcut tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmunro committed Feb 10, 2019
1 parent 4f0f22f commit d4e2aa7
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 9 deletions.
4 changes: 4 additions & 0 deletions tests/selenium/base.py
Expand Up @@ -93,6 +93,10 @@ def by_id(self, el_id):
print(" - finding element by id {0}".format(el_id))
return self.driver.find_element_by_id(el_id)

def by_tag(self, name):
print(" - finding element by tag name {0}".format(name))
return self.driver.find_element_by_tag_name(name)

def by_name(self, name):
print(" - finding element by name {0}".format(name))
return self.driver.find_element_by_name(name)
Expand Down
1 change: 0 additions & 1 deletion tests/selenium/folder_list.py
Expand Up @@ -2,7 +2,6 @@

from base import WebTest, USER, PASS
from runner import test_runner
from selenium.common.exceptions import ElementNotVisibleException

class FolderListTests(WebTest):

Expand Down
2 changes: 0 additions & 2 deletions tests/selenium/inline_msg.py
Expand Up @@ -2,8 +2,6 @@

from base import WebTest, USER, PASS
from runner import test_runner
from selenium.common.exceptions import ElementNotVisibleException
from selenium.webdriver.support.ui import Select
from settings import SettingsHelpers

class InlineMsgTests(SettingsHelpers):
Expand Down
66 changes: 66 additions & 0 deletions tests/selenium/keyboard_shortcuts.py
@@ -0,0 +1,66 @@
#!/usr/bin/python

from base import WebTest, USER, PASS, SITE_URL
from runner import test_runner
from selenium.webdriver.common.keys import Keys
from settings import SettingsHelpers
from selenium.common.exceptions import ElementNotVisibleException


class KeyboardShortcutTests(SettingsHelpers):

def __init__(self):
WebTest.__init__(self)
self.login(USER, PASS)
self.wait_with_folder_list()
self.checkbox_test('general_setting', 'enable_keyboard_shortcuts', False, 'keyboard_shortcuts')

def nav_to_page(self, key_combo, titlestr, title_class):
el = self.by_tag('body')
el.send_keys(key_combo)
self.wait_with_folder_list()
assert self.by_class(title_class).text.startswith(titlestr)

def nav_to_unread(self):
self.nav_to_page(Keys.META + 'u', 'Unread', 'mailbox_list_title')

def nav_to_everything(self):
self.nav_to_page(Keys.META + 'e', 'Everything', 'mailbox_list_title')

def nav_to_flagged(self):
self.nav_to_page(Keys.META + 'f', 'Flagged', 'mailbox_list_title')

def nav_to_history(self):
self.nav_to_page(Keys.META + 'h', 'Message history', 'content_title')

def nav_to_contacts(self):
self.nav_to_page(Keys.META + 'c', 'Contacts', 'content_title')

def nav_to_compose(self):
self.nav_to_page(Keys.META + 's', 'Compose', 'content_title')

def toggle_folders(self):
el = self.by_tag('body')
el.send_keys(Keys.META + 't')
try:
self.by_class('folder_list').click()
assert False == True
except ElementNotVisibleException:
pass
el.send_keys(Keys.META + 't')


if __name__ == '__main__':

print("KEYBOARD SHORTCUT TESTS")
test_runner(KeyboardShortcutTests, [

'nav_to_history',
'nav_to_contacts',
'nav_to_everything',
'nav_to_flagged',
'nav_to_unread',
'nav_to_compose',
'toggle_folders',
'logout'
])
1 change: 0 additions & 1 deletion tests/selenium/profiles.py
@@ -1,6 +1,5 @@
from base import WebTest, USER, PASS
from runner import test_runner
from selenium.common.exceptions import ElementNotVisibleException

class ProfileTest(WebTest):

Expand Down
2 changes: 1 addition & 1 deletion tests/selenium/runall.sh
Expand Up @@ -3,7 +3,7 @@
PYTHON=`which python`
rm -rf __pycache__/

for suite in login.py folder_list.py pages.py profiles.py settings.py servers.py send.py inline_msg.py search.py
for suite in login.py folder_list.py pages.py profiles.py settings.py servers.py send.py inline_msg.py search.py keyboard_shortcuts.py
do
export TEST_SUITE="$suite"
"$PYTHON" -u ./$suite
Expand Down
1 change: 0 additions & 1 deletion tests/selenium/search.py
Expand Up @@ -2,7 +2,6 @@
from base import WebTest, USER, PASS
from creds import RECIP
from runner import test_runner
from selenium.common.exceptions import ElementNotVisibleException

class SearchTest(WebTest):

Expand Down
1 change: 0 additions & 1 deletion tests/selenium/send.py
@@ -1,7 +1,6 @@
from base import WebTest, USER, PASS
from creds import RECIP
from runner import test_runner
from selenium.common.exceptions import ElementNotVisibleException

class SendTest(WebTest):

Expand Down
1 change: 0 additions & 1 deletion tests/selenium/servers.py
@@ -1,7 +1,6 @@
from base import WebTest, USER, PASS
from runner import test_runner
from creds import IMAP_ID
from selenium.common.exceptions import ElementNotVisibleException

class ServersTest(WebTest):

Expand Down
1 change: 0 additions & 1 deletion tests/selenium/settings.py
Expand Up @@ -2,7 +2,6 @@

from base import WebTest, USER, PASS
from runner import test_runner
from selenium.common.exceptions import ElementNotVisibleException
from selenium.webdriver.support.ui import Select


Expand Down

0 comments on commit d4e2aa7

Please sign in to comment.