UI自动化框架遇到的一些question(持续更新)

框架:pytest + selenium + poium (基于python语言)

1、多条测试用例基于登录之后才能做后续操作

解决思路:建立登录函数(or登录类)供其他测试用例统一调用;

遇到问题:登录函数or登录类参数自定义为brower、base_url;测试用例调用一直报错,错误栈信息如下:

 

INTERNALERROR>   File "C:\Users\rwxwin10\AppData\Local\Programs\Python\Python38\lib\site-packages\pluggy\callers.py", line 203, in _multicall
INTERNALERROR>     gen.send(outcome)
INTERNALERROR>   File "f:\testproject\graspAutoTest\conftest.py", line 76, in capture_screenshots
INTERNALERROR>     raise NameError('没有初始化测试报告目录')
INTERNALERROR> NameError: 没有初始化测试报告目录

 

INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "C:\Users\rwxwin10\AppData\Local\Programs\Python\Python38\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "f:\testproject\graspAutoTest\conftest.py", line 34, in pytest_html_results_table_row
INTERNALERROR>     cells.insert(1, html.td(report.description))
INTERNALERROR> AttributeError: 'CollectReport' object has no attribute 'description'

修复bug:登录函数和登录类的参数设置导致的bug,截图信息如下

UI自动化框架遇到的一些question(持续更新)

 

 

 UI自动化框架遇到的一些question(持续更新)

 

 UI自动化框架遇到的一些question(持续更新)

 

 应改为:

UI自动化框架遇到的一些question(持续更新)

 

 

2、pytest、selenium测试用例,有弹窗的情况无法截屏

原因是alert弹框不在DOM中,是一个独立的窗口,此时可以用robot模拟键盘截屏,如下:

Image=newRobot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));

ImageIO.write(image, "png", new File(dirName + File.separator + fileName + ".png"));

3、pytest预期失败生成html报告的钩子

@pytest.mark.xfail(raises=AssertionError) 加在方法前

4、

 

上一篇:HTML quiz1


下一篇:Django polls应用中Django表单传递问题?;.choice_set.all不被调用?;Django choice_id?