1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-29 08:56:23 -07:00

Delete recent test post after its creation was confirmed

This commit is contained in:
Eggbertx 2023-05-22 13:59:21 -07:00
parent c6b80d74df
commit 0b12231f28
5 changed files with 32 additions and 20 deletions

View file

@ -3,9 +3,7 @@ from urllib.parse import urljoin
from urllib.request import urlopen
from selenium import webdriver
from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.edge.webdriver import WebDriver # skipcq: PYL-W0404
from selenium.webdriver.firefox.webdriver import WebDriver # skipcq: PYL-W0404
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.edge.options import Options as EdgeOptions
from selenium.webdriver.firefox.options import Options as FirefoxOptions

View file

@ -1,4 +1,4 @@
import unittest
import urllib.parse
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
@ -6,7 +6,7 @@ from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.select import Select
from . import SeleniumTestCase
from ..util.posting import make_post
from ..util.posting import make_post, delete_post
import random
from ..util.manage import staff_login
@ -16,6 +16,16 @@ class TestManageActions(SeleniumTestCase):
staff_login(self.options)
return super().setUp()
def get_recent_post_link(self, msg_text: str):
trs = self.driver.find_elements(by=By.CSS_SELECTOR, value="#content table tr")
for tr in trs:
tds = tr.find_elements(by=By.TAG_NAME, value="td")
for c in range(len(tds)):
if tds[c].text == msg_text:
# found the post we made
link = tds[c-2].find_element(by=By.LINK_TEXT, value="Post")
return link
def test_login(self):
self.assertEqual(
self.driver.find_element(by=By.CSS_SELECTOR, value="header h1").text,
@ -44,12 +54,22 @@ class TestManageActions(SeleniumTestCase):
self.options.message = old_msg
staff_login(self.options)
self.driver.find_element(by=By.LINK_TEXT, value="Recent posts").click()
tds = self.driver.find_elements(by=By.CSS_SELECTOR, value="#content table td")
post_exists = False
for td in tds:
if td.text == new_msg:
post_exists = True
self.assertTrue(post_exists, "Found recent post in recent posts list")
WebDriverWait(self.driver, 10).until(
EC.url_contains("/manage/recentposts"))
post_link = self.get_recent_post_link(new_msg)
link_href = post_link.get_attribute("href")
self.assertIsNotNone(post_link, "Found recent post in recent posts list")
post_link.click()
WebDriverWait(self.driver, 10).until(
EC.url_contains(link_href)) # link_href should be something like "/seleniumtesting/ref/<threadOP>.html#<postID>"
fragment = urllib.parse.urldefrag(self.driver.current_url).fragment
delete_post(self.options, fragment, self.options.password)
self.options.goto_page("/manage/recentposts")
post_link = self.get_recent_post_link(new_msg)
self.assertIsNone(post_link, "Confirmed that recent post was deleted")
def test_makeBoard(self):
if self.options.board_exists("seleniumtesting"):

View file

@ -1,5 +1,4 @@
from os import path
import unittest
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

View file

@ -1,6 +1,4 @@
from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.edge.webdriver import WebDriver # skipcq: PYL-W0404
from selenium.webdriver.firefox.webdriver import WebDriver # skipcq: PYL-W0404
from selenium.webdriver.remote.webdriver import WebDriver
class LocalStorage():
# from https://stackoverflow.com/a/46361900

View file

@ -1,13 +1,10 @@
from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.edge.webdriver import WebDriver # skipcq: PYL-W0404
from selenium.webdriver.firefox.webdriver import WebDriver # skipcq: PYL-W0404
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.common.by import By
def qrIsVisible(driver: WebDriver):
try:
return driver.find_element(by=By.CSS_SELECTOR, value="div#qr-box").is_displayed()
except:
except Exception:
return False
def enableQR(driver: WebDriver):