• 安装指南
  • 预先阅读
  • 2安装指南
  • 3自动化工具
  • 3.1安装 Git
  • 3.2安装 Python3
  • 3.3安装 setuptools 与 pip
  • 3.4安装 Chrome 浏览器
  • 3.5安装 Chrome 浏览器驱动
  • 3.6安装 RobotFramework 等 python 库
  • 3.7安装 IDE
  • 3.7.1PyCharm / IDEA
  • 3.7.2Visual Studio Code
  • 3.7.3Robotframework-Ride (RIDE) - 不建议用
  • 4常见问题
  • 4.1使用RIDE时在中文Windows下出现Locale问题
  • 4.2在ride脚本运行后页面出现乱码问题解决出现乱码

当我们在本地电脑开发自动化测试,或者在流水线上或其他环境上部署新的跑自动化用例的机子时候,我们需要安装一系列相关的软件包。此文为此给出了安装指南。

安装指南

  1. 范围:
  1. 个人开发用机
  1. 个人开发用的手提电脑、桌面机等
  1. 测试专用虚拟机
  1. 各项目通过GitLab流水线共同使用
  2. 或在甲方内部网络的测试机
  1. 测试专用物理机
  1. APP测试的手机模拟器需要先搭建一个虚拟机,所以用物理机可以更稳定和流畅(待更新)
  1. 操作系统:
  1. 如果是测试专用机,推荐使用 Ubuntu 20,已有Python3,工具支持度好,可自动化程度高,免费,开源,更新及时;但是企业微信无支持。
  2. 个人的本地开发环境,推荐用MacOS 。MacOS terminal 的命令类似Linux,体验良好。Windows 问题很多。
  1. 内存:8G+
  2. CPU内核:4+
  3. 安装工具:
  1. 命令行安装工具

Ubuntu

MacOS

Windows


Ubuntu命令行安装工具apt

Ubuntu命令行安装工具 dpkg, 可以安装下载后的deb包,如:



MacOS命令行安装工具brew


setup.exe

$ sudo apt install -h
  1. Python命令行安装工具 pip,通过阿里云镜像安装各软件,适用于Windows(Admin权限的Git Bash),Ubuntu Linux和MacOS

各类自动化工具

安装 Git

https://git-scm.com/download

Windows 系统会自动安装Git Bash,下面会用得到。

安装 Python3

官方下载地址:https://www.python.org/downloads/
建议下载3.8.x版本的安装包。
下载后双击文件安装,默认安装路径为:C:\Users\Administrator\AppData\Local\Programs\Python\Python38(可自行更改安装路径,安装路径一定不要出现中文汉字)
python安装完成后,必须配置环境变量,在Path变量中加入python的两个路径:

Windows => System => Advanced System Settings => Advanced tab => Environment Variables => Path => Edit => New

C:\Users\Administrator\AppData\Local\Programs\Python\Python38;
C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Scripts。

配置完环境变量,在cmd命令行窗口输入python,提示如下信息表示安装成功。

>python -V
Python 3.8.10

安装 setuptools 与 pip

python安装过程已安装setuptools与pip,此步骤可以省略不做。

查看python是否有安装setuptools与pip,可cmd命令行输入pip list。

编辑pip.ini文件,默认使用阿里云镜像:

默认使用阿里云镜像(新建一个文件夹命名为pip,在新建个.ini后缀的文件,内容存放以下内容)

[global]
index-url=http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com


 

安装 Chrome 浏览器

  1. 推荐用 Chrome - https://www.google.cn/chrome
  1. 如果知道版本号,可以直接下载,例如,在Ubuntu系统下,下载 97.0.4692.71-1:
    wget http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_97.0.4692.71-1_amd64.deb
     
  1. 注意:Chrome 版本98+ 有问题,建议只更新到版本97, https://stackoverflow.com/questions/70967207/selenium-chromedriver-cannot-construct-keyevent-from-non-typeable-key

安装 Chrome 浏览器驱动

Chromedriver(谷歌)下载地址(注意需要与谷歌浏览器版本对应):https://registry.npmmirror.com/binary.html?path=chromedriver/
chromedriver 下载完成解压后,将chromedriver.exe文件放到python安装目录(C:\Users\Administrator\AppData\Local\Programs\Python\Python38)。对应的谷歌浏览器也是如此。Linux 或者 MacOS,推荐将chromedriver安装到 /usr/local/bin。

安装 RobotFramework 等 python 库

按照下载好的 requirements.txt 安装相关的python库:

可新建一个文本,命名为:requirements.txt,内容为

Faker
PyMySQL
SecretStorage
clipboard
pyperclip
requests
robotframework
robotframework-databaselibrary
robotframework-excel
robotframework-faker
robotframework-pythonlibcore
robotframework-requests
robotframework-selenium2library
robotframework-seleniumlibrary
robotframework-seleniumtestability
robotframeworklexer
scrapy
selenium==4.2.0
six==1.11.0
testresources
urllib3==1.26.8
xlrd==1.2.0
xlutils
xlwt

在Python命令窗口,运行以下命令:pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com

安装完毕,1)对照下表确认 python 库版本符合: 

pip list

% pip list
Package                         Version
------------------------------- -----------
chardet                            4.0.0
click                              7.1.2
clipboard                          0.0.4
elasticsearch                      7.10.0
Faker                              9.7.1
pip                                21.3.1
regex                              2021.4.4
requests                           2.26.0
robotframework-ride                1.7.4.2     #(可以不安装)
robotframework                     4.1.1
robotframework-appiumlibrary       1.6.3
robotframework-excel               1.0.0b4
robotframework-faker               5.0.0
robotframework-pythonlibcore       3.0.0
robotframework-requests            0.9.2
robotframework-selenium2library    3.0.0
robotframework-seleniumlibrary     5.1.3
robotframework-seleniumtestability 1.1.0
robotframeworklexer                1.1
selenium                           4.2.0
setuptools                         45.2.0
six                                1.11.0
tornado                            6.1
tox                                3.14.0
uiautomator                        1.0.2
urllib3                            1.26.6
wheel                              0.34.2
wxPython                           4.0.7.post2  #(可以不安装)
xlrd                               1.2.0        #(必须安装此版本:pip install xlrd==1.2.0)
xlutils                            2.0.0
xlwt                               1.3.0
yarl                               1.6.3

 

 

2)运行 robot --help 确认Robot Framework 安装成功并能执行。

Robot Help Page

% robot --help
Robot Framework -- A generic automation framework
 
Version:  4.1 (Python 3.7.9 on darwin)
 
Usage:  robot [options] paths
or:  python -m robot [options] paths
or:  python path/to/robot [options] paths
or:  java -jar robotframework.jar [options] paths
 
Robot Framework is a generic open source automation framework for acceptance
testing, acceptance test-driven development (ATDD) and robotic process
automation (RPA). It has simple, easy-to-use syntax that utilizes the
keyword-driven automation approach. Keywords adding new capabilities are
implemented in libraries using either Python or Java. New higher level
keywords can also be created using Robot Framework's own syntax.
 
The easiest way to execute Robot Framework is using the `robot` command created
as part of the normal installation. Alternatively it is possible to execute
the `robot` module directly like `python -m robot`, where `python` can be
replaced with any supported Python interpreter such as `jython`, `ipy` or
`python3`. Yet another alternative is running the `robot` directory like
`python path/to/robot`. Finally, there is a standalone JAR distribution
available.
 
Tests (or tasks in RPA terminology) are created in files typically having the
`*.robot` extension. Files automatically create test (or task) suites and
directories with these files create higher level suites. When Robot Framework
is executed, paths to these files or directories are given to it as arguments.
 
By default Robot Framework creates an XML output file and a log and a report in
HTML format, but this can be configured using various options listed below.
Outputs in HTML format are for human consumption and XML output for integration
with other systems. XML outputs can also be combined and otherwise further
post-processed with the Rebot tool that is an integral part of Robot Framework.
Run `rebot --help` for more information.
 
Robot Framework is open source software released under Apache License 2.0.
For more information about the framework and the rich ecosystem around it
see http://robotframework.org/.
 
Options
=======
 
--rpa                 Turn on the generic automation mode. Mainly affects
terminology so that "test" is replaced with "task"
in logs and reports. By default the mode is got
from test/task header in data files. New in RF 3.1.
-F --extension value     Parse only files with this extension when executing
a directory. Has no effect when running individual
files or when using resource files. If more than one
extension is needed, separate them with a colon.
Examples: `--extension txt`, `--extension robot:txt`
Starting from RF 3.2 only `*.robot` files are parsed
by default.
-N --name name           Set the name of the top level suite. By default the
name is created based on the executed file or
directory.
-D --doc documentation   Set the documentation of the top level suite.
Simple formatting is supported (e.g. *bold*). If the
documentation contains spaces, it must be quoted.
If the value is path to an existing file, actual
documentation is read from that file.
Examples: --doc "Very *good* example"
--doc doc_from_file.txt
-M --metadata name:value *  Set metadata of the top level suite. Value can
contain formatting and be read from a file similarly
as --doc. Example: --metadata Version:1.2
-G --settag tag *        Sets given tag(s) to all executed tests.
-t --test name *         Select tests by name or by long name containing also
parent suite name like `Parent.Test`. Name is case
and space insensitive and it can also be a simple
pattern where `*` matches anything, `?` matches any
single character, and `[chars]` matches one character
in brackets.
--task name *         Alias to --test. Especially applicable with --rpa.
-s --suite name *        Select suites by name. When this option is used with
--test, --include or --exclude, only tests in
matching suites and also matching other filtering
criteria are selected. Name can be a simple pattern
similarly as with --test and it can contain parent
name separated with a dot. For example, `-s X.Y`
selects suite `Y` only if its parent is `X`.
-i --include tag *       Select tests by tag. Similarly as name with --test,
tag is case and space insensitive and it is possible
to use patterns with `*`, `?` and `[]` as wildcards.
Tags and patterns can also be combined together with
`AND`, `OR`, and `NOT` operators.
Examples: --include foo --include bar*
--include fooANDbar*
-e --exclude tag *       Select test cases not to run by tag. These tests are
not run even if included with --include. Tags are
matched using same rules as with --include.
-R --rerunfailed output  Select failed tests from an earlier output file to be
re-executed. Equivalent to selecting same tests
individually using --test.
-S --rerunfailedsuites output  Select failed suites from an earlier output
file to be re-executed.
--runemptysuite       Executes suite even if it contains no tests. Useful
e.g. with --include/--exclude when it is not an error
that no test matches the condition.
--skip tag *          Tests having given tag will be skipped. Tag can be
a pattern. New in RF 4.0.
--skiponfailure tag *  Tests having given tag will be skipped if they fail.
Tag can be a pattern. New in RF 4.0.
-n --noncritical tag *   Alias for --skiponfailure. Deprecated since RF 4.0.
-c --critical tag *      Opposite of --noncritical. Deprecated since RF 4.0.
-v --variable name:value *  Set variables in the test data. Only scalar
variables with string value are supported and name is
given without `${}`. See --variablefile for a more
powerful variable setting mechanism.
Examples:
--variable str:Hello       =>  ${str} = `Hello`
-v hi:Hi_World -E space:_  =>  ${hi} = `Hi World`
-v x: -v y:42              =>  ${x} = ``, ${y} = `42`
-V --variablefile path *  Python or YAML file file to read variables from.
Possible arguments to the variable file can be given
after the path using colon or semicolon as separator.
Examples: --variablefile path/vars.yaml
--variablefile environment.py:testing
-d --outputdir dir       Where to create output files. The default is the
directory where tests are run from and the given path
is considered relative to that unless it is absolute.
-o --output file         XML output file. Given path, similarly as paths given
to --log, --report, --xunit, and --debugfile, is
relative to --outputdir unless given as an absolute
path. Other output files are created based on XML
output files after the test execution and XML outputs
can also be further processed with Rebot tool. Can be
disabled by giving a special value `NONE`.
Default: output.xml
-l --log file            HTML log file. Can be disabled by giving a special
value `NONE`. Default: log.html
Examples: `--log mylog.html`, `-l NONE`
-r --report file         HTML report file. Can be disabled with `NONE`
similarly as --log. Default: report.html
-x --xunit file          xUnit compatible result file. Not created unless this
option is specified.
--xunitskipnoncritical  Deprecated since RF 4.0 and has no effect anymore.
-b --debugfile file      Debug file written during execution. Not created
unless this option is specified.
-T --timestampoutputs    When this option is used, timestamp in a format
`YYYYMMDD-hhmmss` is added to all generated output
files between their basename and extension. For
example `-T -o output.xml -r report.html -l none`
creates files like `output-20070503-154410.xml` and
`report-20070503-154410.html`.
--splitlog            Split the log file into smaller pieces that open in
browsers transparently.
--logtitle title      Title for the generated log file. The default title
is `<SuiteName> Test Log`.
--reporttitle title   Title for the generated report file. The default
title is `<SuiteName> Test Report`.
--reportbackground colors  Background colors to use in the report file.
Order is `passed:failed:skipped`. Both color names
and codes work. `skipped` can be omitted.
Examples: --reportbackground green:red:yellow
--reportbackground #00E:#E00
--maxerrorlines lines  Maximum number of error message lines to show in
report when tests fail. Default is 40, minimum is 10
and `NONE` can be used to show the full message.
-L --loglevel level      Threshold level for logging. Available levels: TRACE,
DEBUG, INFO (default), WARN, NONE (no logging). Use
syntax `LOGLEVEL:DEFAULT` to define the default
visible log level in log files.
Examples: --loglevel DEBUG
--loglevel DEBUG:INFO
--suitestatlevel level  How many levels to show in `Statistics by Suite`
in log and report. By default all suite levels are
shown. Example:  --suitestatlevel 3
--tagstatinclude tag *  Include only matching tags in `Statistics by Tag`
in log and report. By default all tags are shown.
Given tag can be a pattern like with --include.
--tagstatexclude tag *  Exclude matching tags from `Statistics by Tag`.
This option can be used with --tagstatinclude
similarly as --exclude is used with --include.
--tagstatcombine tags:name *  Create combined statistics based on tags.
These statistics are added into `Statistics by Tag`.
If the optional `name` is not given, name of the
combined tag is got from the specified tags. Tags are
matched using the same rules as with --include.
Examples: --tagstatcombine requirement-*
--tagstatcombine tag1ANDtag2:My_name
--tagdoc pattern:doc *  Add documentation to tags matching the given
pattern. Documentation is shown in `Test Details` and
also as a tooltip in `Statistics by Tag`. Pattern can
use `*`, `?` and `[]` as wildcards like --test.
Documentation can contain formatting like --doc.
Examples: --tagdoc mytag:Example
--tagdoc "owner-*:Original author"
--tagstatlink pattern:link:title *  Add external links into `Statistics by
Tag`. Pattern can use `*`, `?` and `[]` as wildcards
like --test. Characters matching to `*` and `?`
wildcards can be used in link and title with syntax
%N, where N is index of the match (starting from 1).
Examples: --tagstatlink mytag:http://my.domain:Title
--tagstatlink "bug-*:http://url/id=%1:Issue Tracker"
--expandkeywords name:<pattern>|tag:<pattern> *
Matching keywords will be automatically expanded in
the log file. Matching against keyword name or tags
work using same rules as with --removekeywords.
Examples: --expandkeywords name:BuiltIn.Log
--expandkeywords tag:expand
New in RF 3.2.
--removekeywords all|passed|for|wuks|name:<pattern>|tag:<pattern> *
Remove keyword data from the generated log file.
Keywords containing warnings are not removed except
in the `all` mode.
all:     remove data from all keywords
passed:  remove data only from keywords in passed
test cases and suites
for:     remove passed iterations from for loops
wuks:    remove all but the last failing keyword
inside `BuiltIn.Wait Until Keyword Succeeds`
name:<pattern>:  remove data from keywords that match
the given pattern. The pattern is matched
against the full name of the keyword (e.g.
'MyLib.Keyword', 'resource.Second Keyword'),
is case, space, and underscore insensitive,
and may contain `*`, `?` and `[]` wildcards.
Examples: --removekeywords name:Lib.HugeKw
--removekeywords name:myresource.*
tag:<pattern>:  remove data from keywords that match
the given pattern. Tags are case and space
insensitive and patterns can contain `*`,
`?` and `[]` wildcards. Tags and patterns
can also be combined together with `AND`,
`OR`, and `NOT` operators.
Examples: --removekeywords foo
--removekeywords fooANDbar*
--flattenkeywords for|foritem|name:<pattern>|tag:<pattern> *
Flattens matching keywords in the generated log file.
Matching keywords get all log messages from their
child keywords and children are discarded otherwise.
for:     flatten for loops fully
foritem: flatten individual for loop iterations
name:<pattern>:  flatten matched keywords using same
matching rules as with
`--removekeywords name:<pattern>`
tag:<pattern>:  flatten matched keywords using same
matching rules as with
`--removekeywords tag:<pattern>`
--listener class *    A class for monitoring test execution. Gets
notifications e.g. when tests start and end.
Arguments to the listener class can be given after
the name using a colon or a semicolon as a separator.
Examples: --listener MyListenerClass
--listener path/to/Listener.py:arg1:arg2
--nostatusrc          Sets the return code to zero regardless of failures
in test cases. Error codes are returned normally.
--dryrun              Verifies test data and runs tests so that library
keywords are not executed.
-X --exitonfailure       Stops test execution if any critical test fails.
--exitonerror         Stops test execution if any error occurs when parsing
test data, importing libraries, and so on.
--skipteardownonexit  Causes teardowns to be skipped if test execution is
stopped prematurely.
--randomize all|suites|tests|none  Randomizes the test execution order.
all:    randomizes both suites and tests
suites: randomizes suites
tests:  randomizes tests
none:   no randomization (default)
Use syntax `VALUE:SEED` to give a custom random seed.
The seed must be an integer.
Examples: --randomize all
--randomize tests:1234
--prerunmodifier class *  Class to programmatically modify the test suite
structure before execution.
--prerebotmodifier class *  Class to programmatically modify the result
model before creating reports and logs.
--console type        How to report execution on the console.
verbose:  report every suite and test (default)
dotted:   only show `.` for passed test, `f` for
failed non-critical tests, and `F` for
failed critical tests
quiet:    no output except for errors and warnings
none:     no output whatsoever
-. --dotted              Shortcut for `--console dotted`.
--quiet               Shortcut for `--console quiet`.
-W --consolewidth chars  Width of the console output. Default is 78.
-C --consolecolors auto|on|ansi|off  Use colors on console output or not.
auto: use colors when output not redirected (default)
on:   always use colors
ansi: like `on` but use ANSI colors also on Windows
off:  disable colors altogether
Note that colors do not work with Jython on Windows.
-K --consolemarkers auto|on|off  Show markers on the console when top level
keywords in a test case end. Values have same
semantics as with --consolecolors.
-P --pythonpath path *   Additional locations (directories, ZIPs, JARs) where
to search test libraries and other extensions when
they are imported. Multiple paths can be given by
separating them with a colon (`:`) or by using this
option several times. Given path can also be a glob
pattern matching multiple paths.
Examples:
--pythonpath libs/ --pythonpath resources/*.jar
--pythonpath /opt/testlibs:mylibs.zip:yourlibs
-A --argumentfile path *  Text file to read more arguments from. Use special
path `STDIN` to read contents from the standard input
stream. File can have both options and input files
or directories, one per line. Contents do not need to
be escaped but spaces in the beginning and end of
lines are removed. Empty lines and lines starting
with a hash character (#) are ignored.
Example file:
|  --include regression
|  --name Regression Tests
|  # This is a comment line
|  my_tests.robot
|  path/to/test/directory/
Examples:
--argumentfile argfile.txt --argumentfile STDIN
-h -? --help             Print usage instructions.
--version                Print version information.
 
Options that are marked with an asterisk (*) can be specified multiple times.
For example, `--test first --test third` selects test cases with name `first`
and `third`. If an option accepts a value but is not marked with an asterisk,
the last given value has precedence. For example, `--log A.html --log B.html`
creates log file `B.html`. Options accepting no values can be disabled by
using the same option again with `no` prefix added or dropped. The last option
has precedence regardless of how many times options are used. For example,
`--dryrun --dryrun --nodryrun --nostatusrc --statusrc` would not activate the
dry-run mode and would return a normal return code.
 
Long option format is case-insensitive. For example, --SuiteStatLevel is
equivalent to but easier to read than --suitestatlevel. Long options can
also be shortened as long as they are unique. For example, `--logti Title`
works while `--lo log.html` does not because the former matches only --logtitle
but the latter matches --log, --loglevel and --logtitle.
 
Environment Variables
=====================
 
ROBOT_OPTIONS             Space separated list of default options to be placed
in front of any explicit options on the command line.
ROBOT_SYSLOG_FILE         Path to a file where Robot Framework writes internal
information about parsing test case files and running
tests. Can be useful when debugging problems. If not
set, or set to a special value `NONE`, writing to the
syslog file is disabled.
ROBOT_SYSLOG_LEVEL        Log level to use when writing to the syslog file.
Available levels are the same as with --loglevel
command line option and the default is INFO.
ROBOT_INTERNAL_TRACES     When set to any non-empty value, Robot Framework's
internal methods are included in error tracebacks.
 
Examples
========
 
# Simple test run using `robot` command without options.
$ robot tests.robot
 
# Using options.
$ robot --include smoke --name "Smoke Tests" path/to/tests.robot
 
# Executing `robot` module using Python.
$ python -m robot path/to/tests
 
# Running `robot` directory with Jython.
$ jython /opt/robot tests.robot
 
# Executing multiple test case files and using case-insensitive long options.
$ robot --SuiteStatLevel 2 --Metadata Version:3 tests/*.robot more/tests.robot
 
# Setting default options and syslog file before running tests.
$ export ROBOT_OPTIONS="--outputdir results --suitestatlevel 2"
$ export ROBOT_SYSLOG_FILE=/tmp/syslog.txt
$ robot tests.robot

 

 

安装 IDE

选择一个 IDE 做robot framework 文件(.robot)的编辑/运行器,不建议用 RIDE:

PyCharm / IDEA

  1. 安装插件:
  1. Hyper Robot Framework Support (Windows 不要安装,有问题)
  2. Robot Framework Language Server
  3. Robot Framework Support
  4. Run Robot Framework file
  5. YAML
  6. Git

Visual Studio Code

  1. 安装插件:
  1. Python
  2. Robot Framework Intellisense
  3. Robot Framework Language Server
  4. robotframework
  5. robotcode(仅支持python3.8+)
  6. Robotframework Debugger

Robotframework-Ride (RIDE) - 不建议用

  1. 安装 wxPython
  1. pip install wxPython==4.0.7.post2 -i https://mirrors.aliyun.com/pypi/simple/
  1. 安装 robotframework-ride
  1. pip install robotframework-ride -i https://mirrors.aliyun.com/pypi/simple/

常见问题

使用RIDE时在中文Windows下出现Locale问题

   

self.normal = self._get_image(image_list, normal)
File "C:\Users\AIT\AppData\Local\Programs\Python\Python38\lib\site-packages\robotide\ui\images.py", line 91, in _get_image
img = wx.Image(path, wx.BITMAP_TYPE_PNG).ConvertToBitmap()
wx._core.wxAssertionError: C++ assertion "strcmp(setlocale(LC_ALL, NULL), "C") == 0" failed at ..\..\src\common\intl.cpp(1579) in wxLocale::GetInfo(): You probably called setlocale() directly instead of using wxLocale and now there is a mismatch between C/C++ and Windows locale.
Things are going to break, please only change locale by creating wxLocale objects to avoid this!

解决方法

  1. 编辑 site-packages\robotide\ui\images.py 和 site-packages\robotide\application\application.py
     增加一句wx.Locale(wx.LANGUAGE_ENGLISH):

images.py

class TreeImageList(wx.ImageList):
 
def __init__(self):
wx.ImageList.__init__(self, *_SIZE)
self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)  # 增加这一句

application.py

class RIDE(wx.App):
...
def OnInit(self):
# DEBUG To test RTL
# self._initial_locale = wx.Locale(wx.LANGUAGE_ARABIC)
self._initial_locale = wx.Locale(wx.LANGUAGE_ENGLISH)
self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)          # 增加这一句

在ride脚本运行后页面出现乱码问题解决出现乱码

   !worddav19700a0f65b5a9b1ac4531025b9039c4.png|height=319,width=554!

解决方法

   site-packages\robotide\contrib\testrunner\testrunnerplugin.py下的 textctrl.AppendTextRaw(bytes(string, encoding\['SYSTEM'\]))改成 textctrl.AppendTextRaw(bytes(string, encoding\['OUTPUT'\]))