首页 > 其他分享 >Selenium46-添加赛区模块测试准备

Selenium46-添加赛区模块测试准备

时间:2022-12-30 11:22:11浏览次数:38  
标签:赛区 driver element Selenium46 模块 import ID find

新建第一版测试用例实现代码文件

  • 新建包testcasecode
  • 新建文件:test_后台_双创_基础设置_赛区管理_添加赛区_case_v1.py

导入资源

  • 导入各项资源
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium import webdriver
from time import sleep
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains

封装判断元素出现的函数

  • 封装判断元素出现的函数:is_element_present
def is_element_present(how,what):
    try:
        driver.find_element(how,what)
    except NoSuchElementException:
        return False
    return True

打开后台管理网页

  • 打开后台管理网页
driver=webdriver.Firefox()
driver.implicitly_wait(15)
driver.get("http://192.168.58.134:8080/integration/manage")

登录进入双创系统管理

  • 登录进入添加赛区模块
driver.find_element(By.ID,"userName").clear()
driver.find_element(By.ID,"userName").send_keys("root")
driver.find_element(By.ID,"password").clear()
driver.find_element(By.ID,"password").send_keys("12345678")
driver.find_element(By.XPATH,"//span[text()='登录']").click()
sleep(1)

进入赛区管理

  • 进入基础设置-赛区管理
driver.find_element(By.ID,"213").click()#基础设置
WebDriverWait(driver,20).until(expected_conditions.presence_of_element_located((By.XPATH,"//div[@id='213']/img[@class='open']")))
driver.find_element(By.ID,"214").click()#赛区管理
WebDriverWait(driver,20).until(expected_conditions.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@data-itemid='213']")))
WebDriverWait(driver,20).until_not(expected_conditions.presence_of_element_located((By.ID,"Loading")))

标签:赛区,driver,element,Selenium46,模块,import,ID,find
From: https://www.cnblogs.com/sean-test/p/17014423.html

相关文章