ttrss/tests/integration/selenium_test.py

73 lines
2.8 KiB
Python
Raw Normal View History

2023-10-22 10:35:01 +00:00
#!/usr/bin/python3
import os
2023-10-28 08:11:13 +00:00
import unittest
2023-12-02 09:44:21 +00:00
import xmlrunner
2023-10-22 10:35:01 +00:00
from selenium import webdriver
from selenium.webdriver.common.by import By
2023-10-28 08:11:13 +00:00
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
2023-10-22 10:35:01 +00:00
2023-10-28 08:11:13 +00:00
class SeleniumTest(unittest.TestCase):
def setUp(self):
CI_COMMIT_SHORT_SHA = os.getenv("CI_COMMIT_SHORT_SHA")
SELENIUM_GRID_ENDPOINT = os.getenv("SELENIUM_GRID_ENDPOINT")
K8S_NAMESPACE = os.getenv("K8S_NAMESPACE")
2023-10-22 10:35:01 +00:00
2023-10-28 08:11:13 +00:00
self.driver = webdriver.Remote(command_executor=SELENIUM_GRID_ENDPOINT, options=webdriver.ChromeOptions())
self.base_url = f"http://tt-rss-{CI_COMMIT_SHORT_SHA}-app.{K8S_NAMESPACE}.svc.cluster.local/tt-rss"
2023-10-22 10:35:01 +00:00
2023-10-28 08:11:13 +00:00
def tearDown(self):
self.driver.quit()
2023-10-22 10:35:01 +00:00
2023-10-28 08:11:13 +00:00
def test_login(self):
self.driver.get(self.base_url)
2023-10-22 10:35:01 +00:00
2023-10-28 08:11:13 +00:00
assert self.driver.find_element(by=By.CSS_SELECTOR, value="body.ttrss_login")
2023-10-22 10:35:01 +00:00
2023-10-28 08:11:13 +00:00
for name in ["login", "password"]:
field = self.driver.find_element(by=By.CSS_SELECTOR, value=f"input[name='{name}']")
field.clear()
field.send_keys("test")
2023-10-22 10:35:01 +00:00
2023-10-28 08:11:13 +00:00
login_button = self.driver.find_element(by=By.CSS_SELECTOR, value="#dijit_form_Button_0_label")
login_button.click()
2023-10-22 10:35:01 +00:00
2023-10-28 08:11:13 +00:00
def test_index(self):
self.test_login()
2023-10-22 10:35:01 +00:00
2023-10-28 08:11:13 +00:00
assert self.driver.find_element(by=By.CSS_SELECTOR, value="body.ttrss_main")
2023-10-22 10:35:01 +00:00
2023-10-28 08:11:13 +00:00
WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "#feedTree")))
2023-10-22 10:35:01 +00:00
2023-10-28 08:11:13 +00:00
assert self.driver.find_element(by=By.CSS_SELECTOR, value="#feedTree").is_displayed()
2023-10-22 10:44:37 +00:00
2023-10-28 08:11:13 +00:00
self.driver.execute_script("Feeds.open({feed:-4})")
assert self.driver.find_element(by=By.CSS_SELECTOR, value="#headlines-frame").is_displayed()
self.driver.execute_script("Filters.edit()")
assert self.driver.find_element(by=By.CSS_SELECTOR, value="#filterEditDlg").is_displayed()
def test_prefs(self):
self.test_login()
self.driver.get(self.base_url + "/prefs.php")
assert self.driver.find_element(by=By.CSS_SELECTOR, value="body.ttrss_prefs")
2023-11-01 10:40:35 +00:00
WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "#dijit_layout_AccordionPane_1_wrapper")))
2023-10-28 08:11:13 +00:00
assert self.driver.find_element(by=By.CSS_SELECTOR, value="#dijit_layout_AccordionPane_1_wrapper").is_displayed()
self.driver.execute_script("dijit.byId('pref-tabs').selectChild('feedsTab')")
WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "#feedTree")))
assert self.driver.find_element(by=By.CSS_SELECTOR, value="#feedTree").is_displayed()
2023-12-02 09:47:36 +00:00
with open('selenium-report.xml', 'wb') as output:
unittest.main(testRunner=xmlrunner.XMLTestRunner(output=output), failfast=False, buffer=False, catchbreak=False)