---
title: "【ChatGPT】游戏自动化测试实践案例 - 敏感词过滤"
author: "Perrin Yong"
author_profile: https://www.pystone.net/profile/
published_by: "Perrin Yong"
canonical: https://www.pystone.net/notes/chatgpt-game-autotest-sensitive-word-filter/
type: note
content_role: unspecified
visibility: public
id_stability: rename-stable
source_path: "99-资料来源、摘录与归档/02-AI对话与研究原始输出/【ChatGPT】游戏自动化测试实践案例 - 敏感词过滤.md"
content_hash: e806d2eb1f19786aa5a4c57e9020250c4f7a5d0624eceb85599ef0847c357ef0
knowledge_version: 224c990773de.5fa8af6e39fa
site_commit: 224c990773de166d23a886306577dd90379529ce
notes_commit: 5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a
---
# 【ChatGPT】游戏自动化测试实践案例 - 敏感词过滤

> **note · ChatGPT 问答录**
> 本文保存一次 ChatGPT 问答原始输出，仅作为资料来源；其中结论未自动视为已验证知识，使用前应结合可靠来源复核。


> 创建时间：2023/6/11 19:08

一个简单的示例：

python

from airtest.core.api import connect_device, time

from poco.drivers.unity3d import UnityPoco

## 连接到目标设备device = connect_device("Android:///")

## 初始化 Pocopoco = UnityPoco(device)

def test_sensitive_word_filtering(): for word in sensitive_words:

## 点击输入框并输入敏感词 input_box = poco("input_box")

input_box.click()

text("word")

time.sleep(1)

## 点击发送按钮 send_button = poco("send_button")

send_button.click()

time.sleep(1)

## 检查敏感词是否被过滤 message = poco("message")

assert message.get_text() == "***", f"敏感词 {word} 未被过滤！"

test_sensitive_word_filtering()

在上述示例中，我们首先连接到目标设备并初始化 Poco。然后，我们遍历敏感词列表，逐个输入敏感词并点击发送按钮。最后，我们检查应用程序是否成功地过滤了这些敏感词（将其替换为 "***"）。
