seldom
seldom copied to clipboard
在jenkins中运行出现 编码错误
File "C:\Users\zhongxiaoyue\AppData\Roaming\Python\Python37\site-packages\seldom\webdriver.py", line 512, in get_text
log.info("\u2705 {info}, get text: {text}.".format(info=web_elem.info, text=elem.text))
File "C:\Users\zhongxiaoyue\AppData\Roaming\Python\Python37\site-packages\seldom\logging\log.py", line 45, in info
_logger.info(Fore.GREEN + now + " [INFO] " + str(msg) + Style.RESET_ALL)
Message: '\x1b[32m2021-08-25 18:26:29 [INFO] \u2705 Find 1 element: xpath=//button[@class="popup-btn"] , get text: .\x1b[0m'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
File "C:\Program Files\Python37\lib\logging\__init__.py", line 985, in emit
stream.write(msg)
UnicodeEncodeError: 'gbk' codec can't encode character '\u2705' in position 32: illegal multibyte sequence
增加color Log 开关
import seldom
from seldom.logging import log
class BaiduTest(seldom.TestCase):
def test_case(self):
"""a simple test case """
self.open("https://www.baidu.com")
self.type(id_="kw", text="seldom")
self.click(id_="su")
if __name__ == '__main__':
log.colorLog = False #关闭 colorLog, 不现实日志颜色以及过滤emoji表情
seldom.main(browser="ff", debug=True)
log
python .\test_sample.py
2021-08-27 00:38:59 [INFO] A run the test in debug mode without generating HTML report!
2021-08-27 00:38:59 [INFO]
__ __
________ / /___/ /___ ____ ____
/ ___/ _ \/ / __ / __ \/ __ ` ___/
(__ ) __/ / /_/ / /_/ / / / / / /
/____/\___/_/\__,_/\____/_/ /_/ /_/
-----------------------------------------
@itest.info
test_case (selenium_sample.BaiduTest)
a simple test case ... 2021-08-27 00:38:59 [INFO] https://www.baidu.com
2021-08-27 00:39:01 [INFO] Find 1 element: id=kw , input 'seldom'.
2021-08-27 00:39:02 [INFO] Find 1 element: id=su , click.
ok
----------------------------------------------------------------------
Ran 1 test in 3.671s
OK
2021-08-27 00:39:03 [INFO] generated log file: file:///D:\github\seldom\reports\2021_08_27_00_38_52_log.log
seldom 2.2.3 已经发布