Skip to content

Commit

Permalink
修复了一些已知问题
Browse files Browse the repository at this point in the history
  • Loading branch information
mikigo committed Aug 16, 2024
1 parent 2855ab3 commit 099714d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 21 deletions.
1 change: 1 addition & 0 deletions docs/指南/与生俱来/前后钩子.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ my_case
├── case
├── method
├── job_end.py # [!code focus]
├── job_end.sh # [!code focus]
...
```
Expand Down
10 changes: 4 additions & 6 deletions docs/指南/可选功能/HTML报告.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

YouQu3 默认生成测试报告 `元数据`,支持通过`报告生成器`生成 HTML 报告。

### 服务器生成模式 <Badge type="warning" text="默认" />
## 服务器生成模式(默认)

YouQu3 在所有用例执行完之后,默认使用远程测试报告生成服务器生成 HTML 报告,并暴露 HTTP 服务,且 HTTP 服务的 URL 会返回给测试机生成到 report 目录下,用户可以随时访问。

Expand All @@ -12,9 +12,7 @@ YouQu3 在所有用例执行完之后,默认使用远程测试报告生成服

2、测试报告可以做持久化留存,随时可以访问,不用担心测试机上被删掉或重装,任何的流水线都不需要再单独处理测试报告数据持久化的问题。

3、YouQu3 可以做简易版的调用次数统计,之前我一直在想,如何能方便的统计 YouQu 框架到底被使用了多少次,或许测试报告服务器模式是一种比较简单粗暴但很直接的统计方法。

#### 插件安装
### 插件安装

基础环境并不包含报告生成器,需要指定安装报告插件或测试类型,如:

Expand All @@ -28,11 +26,11 @@ pip3 install youqu-html-rpc
pip3 install "youqu3[gui]"
```

### 本地生成模式 <Badge type="warning" text="youqu-html 插件" />
## 本地生成模式

如果已安装插件 `youqu-html` ,YouQu3 默认在本地生成 HTML 测试报告,您可以在 report 查看。

#### 插件安装
### 插件安装

```bash
pip3 install youqu-html
Expand Down
2 changes: 2 additions & 0 deletions docs/指南/可选功能/WebUI.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# WebUI

基于 Playwright 实现。

## 安装

```bash
Expand Down
10 changes: 5 additions & 5 deletions docs/指南/可选功能/用例录屏.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 用例录屏
# 用例录屏

录屏其实是一种视频形式的日志,因为很多时候我们在查看日志之后仍然无法准确的定位到用例失败的具体原因,因此用例的录屏能让我们看到用例在执行过程;

Expand All @@ -10,8 +10,8 @@ pip3 install "youqu3[gui]"

录制的视频会被加载到 HTML 测试报告中。

### 失败录屏 <Badge type="warning" text="默认" />
## 失败录屏
🚧



### 关闭录屏
## 关闭录屏
🚧
22 changes: 12 additions & 10 deletions youqu3/assertx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
# SPDX-License-Identifier: GPL-2.0-only
import os
from funnylog2.config import config as funnylog2_config
from typing import Union

from funnylog2.config import config as funnylog2_config
from youqu3 import exceptions
from youqu3 import log, logger, setting
from youqu3.cmd import Cmd
Expand Down Expand Up @@ -43,8 +43,8 @@ def assert_image_exist(
timeout=timeout,
max_match_number=match_number,
)
except exceptions.TemplateElementNotFound as exc:
raise AssertionError(exc) from exceptions.TemplateElementNotFound
except pylinuxauto.exceptions.TemplateElementNotFound as exc:
raise AssertionError(exc) from pylinuxauto.exceptions.TemplateElementNotFound

@staticmethod
def assert_image_not_exist(
Expand All @@ -71,9 +71,9 @@ def assert_image_not_exist(
max_match_number=match_number,
)
raise exceptions.TemplateElementFound(widget)
except exceptions.TemplateElementNotFound:
except pylinuxauto.exceptions.TemplateElementNotFound:
pass
except exceptions.TemplateElementFound as exc:
except pylinuxauto.exceptions.TemplateElementFound as exc:
raise AssertionError(exc) from exceptions.TemplateElementFound

@classmethod
Expand Down Expand Up @@ -114,19 +114,21 @@ def assert_file_not_exist(file_path):

@staticmethod
def assert_element_exist(expr):
"""判断元素{{expr}}不存在"""
"""判断元素{{expr}}存在"""
from youqu3.gui import pylinuxauto
if not pylinuxauto.find_element_by_attr_path(expr):
raise AssertionError(f"元素{expr}不存在")
try:
pylinuxauto.find_element_by_attr_path(expr)
except pylinuxauto.exceptions.ElementNotFound:
raise exceptions.ElementNotFound(expr)

@staticmethod
def assert_element_not_exist(expr):
"""判断元素{{expr}}不存在"""
from youqu3.gui import pylinuxauto
try:
pylinuxauto.find_element_by_attr_path(expr)
raise AssertionError(f"元素{expr}存在")
except exceptions.ElementNotFound:
raise exceptions.ElementFound(expr)
except pylinuxauto.exceptions.ElementNotFound:
pass

@staticmethod
Expand Down
8 changes: 8 additions & 0 deletions youqu3/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ def __init__(self, result):
Exception.__init__(self, err)


class ElementFound(Exception):

def __init__(self, name):
err = f"找到元素: {name}"
logger.error(err)
Exception.__init__(self, err)


class ElementNotFound(Exception):

def __init__(self, name):
Expand Down

0 comments on commit 099714d

Please sign in to comment.