TA的每日心情 | 无聊 昨天 09:47 |
---|
签到天数: 528 天 连续签到: 1 天 [LV.9]测试副司令
|
1测试积点
[color=rgba(0, 0, 0, 0.75)]常规定位元素方法基本上都试过了,定位不到。各位看看还有什么方法能进行元素定位
- from tkinter import Image
- import ddt
- import unittest2
- from upl.webUtil import *
- #
- import pytesseract
- from PIL import Image
- from PIL import Image, ImageEnhance
- import os
- import time
- @ddt.ddt()
- class UPL_Test(unittest2.TestCase):
- def setUp(self) -> None:
- self.driver = WebDriverUtil(path='chromedriver.exe')
- self.driver.get("http://192.168.59.122/user/login")
- self.driver.read("xpath.json")
- @ddt.file_data("data.json")
- def test(self, login):
- # 登录
- self.login(login)
- #音视频管理
- self.video()
- def login(self, login):
- self.driver.section = "login"
- # 进入登录页面
- # self.driver.get(login["url"])
- # 用户名输入
- self.driver.find_element("name").send_keys(login["name"])
- # 密码输入
- self.driver.find_element("password").send_keys(login["password"])
- # 获取验证码
- self.driver.find_element("code").send_keys(login["code"])#yzm()
- # 点击登录按钮
- self.driver.driver.implicitly_wait(5)
- self.driver.find_element("button").click()
- def video(self):
- self.driver.section="video"
- time.sleep(2)
- #点击节目单管理
- self.driver.find_element("programme").click()
- #新增
- self.driver.find_element("p_add").click()
- time.sleep(10)
- if __name__ == '__main__':
- unittest2.main()
复制代码 xpath.json
- {
- "login": {
- "name": {
- "type": "id",
- "value": "username"
- },
- "password": {
- "type":"id",
- "value": "password"
- },
- "code": {
- "type": "id",
- "value": "inputCode"
- },
- "button": {
- "type": "xpath",
- "value": "//*[@id='formLogin']/div[2]/div/div/span/button"
- },
- "code_image": {
- "type": "xpath",
- "value": "//form[@id='formLogin']/div[1]/div[3]/div/div[4]/div[2]/img"
- }
- },
- "video": {
- "programme": {
- "type": "xpath",
- "value": "//*[@id='app']/section/aside/div/ul/li[9]/ul/li[2]/a/span"
- },
- "p_add": {
- "type": "xpath",
- "value": "//*[@id='app']/section/section/main/div[2]/div/div/div/div[2]/button"
- }
- }
- }
复制代码
|
|