From dfc42953f7519efb86b24b8ae0cab3698b09b66f Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Wed, 4 Mar 2020 17:02:34 -0600 Subject: [PATCH] added mail browser test file --- tests/browser-tests/test-mail.py | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/browser-tests/test-mail.py diff --git a/tests/browser-tests/test-mail.py b/tests/browser-tests/test-mail.py new file mode 100644 index 00000000..d2c35f90 --- /dev/null +++ b/tests/browser-tests/test-mail.py @@ -0,0 +1,50 @@ +import sys, os +sys.path.append(".") +sys.path.append("src/") +import unittest, uuid +TEST_DIR = 'testdata/-%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' +os.environ["ONIONR_HOME"] = TEST_DIR +from unittest.mock import patch + +from utils import createdirs + +from subprocess import Popen +import subprocess +from time import sleep + +from helium import start_firefox, click, Text, Config + + +from onionrcommands.openwebinterface import get_url +from onionrutils import escapeansi +BROWSER_HEADLESS = os.getenv('ONIONR_TEST_HEADLESS') + +Config.implicit_wait_secs = 30 + +def start_onionr(): + testargs = ["onionr.py", "start"] + with patch.object(sys, 'argv', testargs): + parser.register() + + +class OnionrTests(unittest.TestCase): + def test_mail_home_load(self): + Popen(['./onionr.sh', 'start']) + while b'http' not in Popen(['./onionr.sh', 'url'], stdout=subprocess.PIPE).communicate()[0]: + sleep(1) + + url = 'http' + escapeansi.escape_ANSI(Popen(['./onionr.sh', 'url'], stdout=subprocess.PIPE).communicate()[0].decode().split('http')[1]) + web_driver = start_firefox(url=url, headless=BROWSER_HEADLESS) + if not Text('Mail').exists(): + click('Get Started') + sleep(2) + click('Mail') + sleep(5) + if not Text('Mail').exists(): + Popen(['./onionr.sh', 'stop']).wait() + web_driver.quit() + raise ValueError + Popen(['./onionr.sh', 'stop']).wait() + web_driver.quit() + +unittest.main()