From 4ff33b377f7c06576a158f7cbbb34d234e06bbfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E6=A2=93=E9=94=9F?= <1640384813@qq.com> Date: Fri, 17 May 2024 15:31:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20test=5Fbug561=5FWanZiKun.p?= =?UTF-8?q?y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新test内容并更换位置 --- test_bug561_WanZiKun.py | 64 ----------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 test_bug561_WanZiKun.py diff --git a/test_bug561_WanZiKun.py b/test_bug561_WanZiKun.py deleted file mode 100644 index 66d3afd..0000000 --- a/test_bug561_WanZiKun.py +++ /dev/null @@ -1,64 +0,0 @@ -import time -import pytest -import uuid -from selenium import webdriver -from selenium.webdriver import ActionChains -from selenium.webdriver.common.by import By -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support import expected_conditions as EC -from selenium.common.exceptions import UnexpectedAlertPresentException, NoAlertPresentException, NoSuchElementException, TimeoutException - -def signup(URL, driver): - username = 'TestUser' + str(uuid.uuid1()).split('-')[0].title() - password = '[Abc+123]' - - driver.get(URL) - try: - elem = driver.find_element_by_link_text('注册') - elem.click() - elem = driver.find_element_by_id('username') - elem.send_keys(username) - elem = driver.find_element_by_id('password') - elem.send_keys(password) - elem = driver.find_element_by_id('password2') - elem.send_keys(password) - elem = driver.find_element_by_class_name('btn') - elem.click() - - WebDriverWait(driver, 10).until(EC.alert_is_present()) - driver.switch_to.alert.accept() - print(f"Registration successful: {username}") - except (UnexpectedAlertPresentException, NoAlertPresentException, TimeoutException, NoSuchElementException) as e: - print(f"Error during signup: {e}") - driver.quit() - raise - - return username, password - -def test_bug561(): - driver = webdriver.Edge() - try: - driver.maximize_window() - base_url = "http://118.25.96.118:90/" - username, password = signup(base_url, driver) - - article = driver.find_element(By.ID, 'article') - actions = ActionChains(driver) - actions.move_to_element(article) - actions.click_and_hold() - actions.move_by_offset(450, 200) - actions.release() - actions.perform() - print("Performed actions on article.") - - next_button = driver.find_element(By.ID, 'load_next_article') - next_button.click() - WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'load_pre_article'))) - print("Clicked next article button.") - - prev_button = driver.find_element(By.ID, 'load_pre_article') - prev_button.click() - print("Clicked previous article button.") - finally: - driver.quit() - print("Driver closed.")