GithubHelp home page GithubHelp logo

airtest-selenium's Introduction

Airtest Project </style>

1.5 web自动化测试

前言

Selenium是一款web自动化测试框架,它支持各种浏览器,包括 Chrome,Safari,Firefox 等主流浏览器。

得益于Selenium对Python的良好支持,我们在Airtest Project中添加了Airtest-Selenium插件,我们可以使用AirtestIDE进行web自动化脚本录制、脚本运行和报告生成。本文将介绍如何使用AirtestIDE进行web自动化测试。

Airtest-Selenium测试框架原理图

录制视频示例

demo

相关链接

Airtest-Selenium快速上手教程: http://airtest.netease.com/docs/docs_AirtestIDE-zh_CN/1_quick_start/5_get_started_with_web_test.html

Airtest-Selenium详细文档及API: http://airtest.netease.com/docs/cn/8_plugins/2_selenium.html

airtest-selenium's People

Contributors

yimelia avatar zzldjkzxf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

airtest-selenium's Issues

Airtest_touch中双击图片threshold修改无效,还是使用默认的值,设置了全局变量也还是一样的情况

(请尽量按照下面提示内容填写,有助于我们快速定位和解决问题,感谢配合。否则直接关闭。)

(重要!问题分类)

描述问题bug
(简洁清晰得概括一下遇到的问题是什么。或者是报错的traceback信息。)
Airtest_touch中双击图片threshold修改无效,还是使用默认的值,设置了全局变量也还是一样的情况。
image

image

(在这里粘贴traceback或其他报错信息)

相关截图
(贴出遇到问题时的截图内容,如果有的话)
(在AirtestIDE里产生的图像和设备相关的问题,请贴一些AirtestIDE控制台黑窗口相关报错信息)

复现步骤

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

预期效果
(预期想要得到什么、见到什么)

python 版本: python3.5

airtest 版本: 1.0.69

airtest版本通过pip freeze可以命令可以查到

设备:

  • 型号: [e.g. google pixel 2]
  • 系统: [e.g. Android 8.1]
  • (别的信息)

其他相关环境信息
(其他运行环境,例如在linux ubuntu16.04上运行异常,在windows上正常。)

希望能升级对selenium4的支持

在本地selenium4的情况下运行airtest_selenium的driver.find_element_by_id
会提示UserWarning: find_element_by_* commands are deprecated. Please use find_element() instead
这个warning不理会也没问题,还是觉得老的写法方便。
下面我把proxy.py文件里的loop_find_element增加了个by参数

def loop_find_element(self, func,by, text, timeout=10, interval=0.5):
        """
        Loop to find the target web element by func.

        Args:
            func: function to find element
            text: param of function
            timeout: time to find the element
            interval: interval between operation
        Returns:
            element that been found
        """
        start_time = time.time()
        while True:
            try:
                element = func(by,text)
            except NoSuchElementException:
                print("Element not found!")
                # 超时则raise,未超时则进行下次循环:
                if (time.time() - start_time) > timeout:
                    # try_log_screen(screen)
                    raise NoSuchElementException(
                        'Element %s not found in screen' % text)
                else:
                    time.sleep(interval)
            else:
                return element

把find_element_by_id改成了如下

    def find_element_by_id(self, id):
        """
        Find the web element by id.

        Args:
            id: find the element by attribute id.
        Returns:
            Web element of current page.
        """
        web_element = self.loop_find_element(super(WebChrome, self).find_element,By.ID, id)
        log_res = self._gen_screen_log(web_element)
        return Element(web_element, log_res)

这样既能享受老版本的find_element_by_id的方便,还不会因为selenium版本太高而总弹出warning,不会pr,只能贴到这里了,希望能更新下,非常感谢。

如何在把setup中的driver传给其他的air用例

需求

  • 想实现并行多浏览器

问题点

  • 官网例子直接在air文件中运行,我需要在runner中写driver,然后air文件获取driver
  • runner如下所示:
# runner
class CustomAirtestCase(AirtestCase):

    def setUp(self):
        super(CustomAirtestCase, self).setUp()
       self.driver = .....
      # 处理登录等问题...

  • 用例air
driver = ??? # 如果获取到setup中的driver
driver.find_element_by_id("kw").send_keys("baidu")

使用Airtest_Selenium进行web自动化测试,图像识别位置与实际点击位置不一致

问题分类:图像识别,Airtest_Selenium,Web自动化测试

描述问题bug
场景:执行web自动化脚本时,图像识别位置与实际点击的位置不一致。但是运行时并未报错(日志没有显示异常)

(在这里粘贴traceback或其他报错信息)


[Start running..]
save log in 'D:/Air_Test/logs\7c2609c6e2bde6a70ae8b909a4d8ad3f'
this is jpg path:
D:/Air_Test/logs\7c2609c6e2bde6a70ae8b909a4d8ad3f\1557979217.jpg
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
this is jpg path:
D:/Air_Test/logs\7c2609c6e2bde6a70ae8b909a4d8ad3f\1557979219.jpg
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
this is jpg path:
D:/Air_Test/logs\7c2609c6e2bde6a70ae8b909a4d8ad3f\1557979220.jpg
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
this is jpg path:
D:/Air_Test/logs\7c2609c6e2bde6a70ae8b909a4d8ad3f\1557979221.jpg
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:22][INFO]<airtest.core.api> Try finding:
Template(D:\test_related\Airtest\test_cases\sirius_demo.air\tpl1557909501004.png)
[12:00:22][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:23][DEBUG]<airtest.aircv.keypoint_base> find_best_result() run time is 0.54 s.
[12:00:23][DEBUG]<airtest.core.api> try match with TemplateMatching
[12:00:23][DEBUG]<airtest.aircv.template_matching> [Template] threshold=0.7, result={'result': (1102, 147), 'rectangle': ((1010, 120), (1010, 175), (1194, 175), (1194, 120)), 'confidence': 0.7079585790634155}
[12:00:23][DEBUG]<airtest.aircv.template_matching> find_best_result() run time is 0.05 s.
[12:00:23][DEBUG]<airtest.core.api> match result: {'result': (1102, 147), 'rectangle': ((1010, 120), (1010, 175), (1194, 175), (1194, 120)), 'confidence': 0.7079585790634155}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:23][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:23][DEBUG]<airtest.core.api> 'Not enough feature points in input images !'
[12:00:23][DEBUG]<airtest.core.api> try match with TemplateMatching
[12:00:23][DEBUG]<airtest.aircv.template_matching> [Template] threshold=0.6, result={'result': (733, 230), 'rectangle': ((699, 214), (699, 247), (768, 247), (768, 214)), 'confidence': 0.9995008111000061}
[12:00:23][DEBUG]<airtest.aircv.template_matching> find_best_result() run time is 0.04 s.
[12:00:23][DEBUG]<airtest.core.api> match result: {'result': (733, 230), 'rectangle': ((699, 214), (699, 247), (768, 247), (768, 214)), 'confidence': 0.9995008111000061}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:25][INFO]<airtest.core.api> Try finding:
Template(D:\test_related\Airtest\test_cases\sirius_demo.air\tpl1557907382510.png)
[12:00:25][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:25][DEBUG]<airtest.aircv.keypoint_base> [SURF] threshold=0.7, result={'result': (100, 403), 'rectangle': [(10, 186), (10, 620), (190, 620), (190, 186)], 'confidence': 0.6810221523046494}
[12:00:25][DEBUG]<airtest.aircv.keypoint_base> find_best_result() run time is 0.40 s.
[12:00:25][DEBUG]<airtest.core.api> try match with TemplateMatching
[12:00:25][DEBUG]<airtest.aircv.template_matching> [Template] threshold=0.7, result={'result': (101, 404), 'rectangle': ((11, 187), (11, 621), (192, 621), (192, 187)), 'confidence': 0.9993710517883301}
[12:00:25][DEBUG]<airtest.aircv.template_matching> find_best_result() run time is 0.06 s.
[12:00:25][DEBUG]<airtest.core.api> match result: {'result': (101, 404), 'rectangle': ((11, 187), (11, 621), (192, 621), (192, 187)), 'confidence': 0.9993710517883301}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:26][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:26][DEBUG]<airtest.aircv.keypoint_base> find_best_result() run time is 0.20 s.
[12:00:26][DEBUG]<airtest.core.api> try match with TemplateMatching
[12:00:26][DEBUG]<airtest.aircv.template_matching> [Template] threshold=0.6, result={'result': (104, 181), 'rectangle': ((20, 166), (20, 196), (189, 196), (189, 166)), 'confidence': 0.9995023012161255}
[12:00:26][DEBUG]<airtest.aircv.template_matching> find_best_result() run time is 0.04 s.
[12:00:26][DEBUG]<airtest.core.api> match result: {'result': (104, 181), 'rectangle': ((20, 166), (20, 196), (189, 196), (189, 166)), 'confidence': 0.9995023012161255}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:27][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:28][DEBUG]<airtest.core.api> 'Not enough feature points in input images !'
[12:00:28][DEBUG]<airtest.core.api> try match with TemplateMatching
[12:00:28][DEBUG]<airtest.aircv.template_matching> [Template] threshold=0.6, result={'result': (78, 224), 'rectangle': ((43, 213), (43, 236), (113, 236), (113, 213)), 'confidence': 0.9992191195487976}
[12:00:28][DEBUG]<airtest.aircv.template_matching> find_best_result() run time is 0.04 s.
[12:00:28][DEBUG]<airtest.core.api> match result: {'result': (78, 224), 'rectangle': ((43, 213), (43, 236), (113, 236), (113, 213)), 'confidence': 0.9992191195487976}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:29][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:30][DEBUG]<airtest.aircv.keypoint_base> [SURF] threshold=0.6, result={'result': (1177, 163), 'rectangle': [(1142, 147), (1142, 179), (1212, 179), (1212, 147)], 'confidence': 0.7275830209255219}
[12:00:30][DEBUG]<airtest.aircv.keypoint_base> find_best_result() run time is 0.31 s.
[12:00:30][DEBUG]<airtest.core.api> match result: {'result': (1177, 163), 'rectangle': [(1142, 147), (1142, 179), (1212, 179), (1212, 147)], 'confidence': 0.7275830209255219}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:31][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:32][DEBUG]<airtest.aircv.keypoint_base> find_best_result() run time is 0.36 s.
[12:00:32][DEBUG]<airtest.core.api> try match with TemplateMatching
[12:00:32][DEBUG]<airtest.aircv.template_matching> [Template] threshold=0.6, result={'result': (1106, 164), 'rectangle': ((1075, 147), (1075, 181), (1137, 181), (1137, 147)), 'confidence': 0.987464189529419}
[12:00:32][DEBUG]<airtest.aircv.template_matching> find_best_result() run time is 0.04 s.
[12:00:32][DEBUG]<airtest.core.api> match result: {'result': (1106, 164), 'rectangle': ((1075, 147), (1075, 181), (1137, 181), (1137, 147)), 'confidence': 0.987464189529419}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:34][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:34][DEBUG]<airtest.aircv.keypoint_base> find_best_result() run time is 0.33 s.
[12:00:34][DEBUG]<airtest.core.api> try match with TemplateMatching
[12:00:34][DEBUG]<airtest.aircv.template_matching> [Template] threshold=0.6, result={'result': (1254, 166), 'rectangle': ((1222, 151), (1222, 182), (1287, 182), (1287, 151)), 'confidence': 0.9992009401321411}
[12:00:34][DEBUG]<airtest.aircv.template_matching> find_best_result() run time is 0.04 s.
[12:00:34][DEBUG]<airtest.core.api> match result: {'result': (1254, 166), 'rectangle': ((1222, 151), (1222, 182), (1287, 182), (1287, 151)), 'confidence': 0.9992009401321411}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
this is jpg path:
D:/Air_Test/logs\7c2609c6e2bde6a70ae8b909a4d8ad3f\1557979235.jpg
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:39][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:39][DEBUG]<airtest.core.api> 'Not enough feature points in input images !'
[12:00:39][DEBUG]<airtest.core.api> try match with TemplateMatching
[12:00:39][DEBUG]<airtest.aircv.template_matching> [Template] threshold=0.6, result={'result': (75, 265), 'rectangle': ((41, 254), (41, 277), (110, 277), (110, 254)), 'confidence': 0.9992488622665405}
[12:00:39][DEBUG]<airtest.aircv.template_matching> find_best_result() run time is 0.04 s.
[12:00:39][DEBUG]<airtest.core.api> match result: {'result': (75, 265), 'rectangle': ((41, 254), (41, 277), (110, 277), (110, 254)), 'confidence': 0.9992488622665405}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:41][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:41][DEBUG]<airtest.aircv.keypoint_base> [SURF] threshold=0.6, result={'result': (1177, 163), 'rectangle': [(1142, 147), (1142, 179), (1212, 179), (1212, 147)], 'confidence': 0.7275830209255219}
[12:00:41][DEBUG]<airtest.aircv.keypoint_base> find_best_result() run time is 0.27 s.
[12:00:41][DEBUG]<airtest.core.api> match result: {'result': (1177, 163), 'rectangle': [(1142, 147), (1142, 179), (1212, 179), (1212, 147)], 'confidence': 0.7275830209255219}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:43][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:43][DEBUG]<airtest.aircv.keypoint_base> find_best_result() run time is 0.25 s.
[12:00:43][DEBUG]<airtest.core.api> try match with TemplateMatching
[12:00:43][DEBUG]<airtest.aircv.template_matching> [Template] threshold=0.6, result={'result': (1106, 164), 'rectangle': ((1075, 147), (1075, 181), (1137, 181), (1137, 147)), 'confidence': 0.9874595403671265}
[12:00:43][DEBUG]<airtest.aircv.template_matching> find_best_result() run time is 0.04 s.
[12:00:43][DEBUG]<airtest.core.api> match result: {'result': (1106, 164), 'rectangle': ((1075, 147), (1075, 181), (1137, 181), (1137, 147)), 'confidence': 0.9874595403671265}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:45][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:45][DEBUG]<airtest.core.api> 'Not enough feature points in input images !'
[12:00:45][DEBUG]<airtest.core.api> try match with TemplateMatching
[12:00:45][DEBUG]<airtest.aircv.template_matching> [Template] threshold=0.6, result={'result': (75, 307), 'rectangle': ((35, 297), (35, 318), (115, 318), (115, 297)), 'confidence': 0.9858896136283875}
[12:00:45][DEBUG]<airtest.aircv.template_matching> find_best_result() run time is 0.03 s.
[12:00:45][DEBUG]<airtest.core.api> match result: {'result': (75, 307), 'rectangle': ((35, 297), (35, 318), (115, 318), (115, 297)), 'confidence': 0.9858896136283875}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:47][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:47][DEBUG]<airtest.aircv.keypoint_base> [SURF] threshold=0.6, result={'result': (1177, 163), 'rectangle': [(1142, 147), (1142, 179), (1212, 179), (1212, 147)], 'confidence': 0.7275830209255219}
[12:00:47][DEBUG]<airtest.aircv.keypoint_base> find_best_result() run time is 0.23 s.
[12:00:47][DEBUG]<airtest.core.api> match result: {'result': (1177, 163), 'rectangle': [(1142, 147), (1142, 179), (1212, 179), (1212, 147)], 'confidence': 0.7275830209255219}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:49][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:49][DEBUG]<airtest.aircv.keypoint_base> find_best_result() run time is 0.27 s.
[12:00:49][DEBUG]<airtest.core.api> try match with TemplateMatching
[12:00:49][DEBUG]<airtest.aircv.template_matching> [Template] threshold=0.6, result={'result': (1106, 164), 'rectangle': ((1075, 147), (1075, 181), (1137, 181), (1137, 147)), 'confidence': 0.9874595403671265}
[12:00:49][DEBUG]<airtest.aircv.template_matching> find_best_result() run time is 0.04 s.
[12:00:49][DEBUG]<airtest.core.api> match result: {'result': (1106, 164), 'rectangle': ((1075, 147), (1075, 181), (1137, 181), (1137, 147)), 'confidence': 0.9874595403671265}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
[12:00:51][DEBUG]<airtest.core.api> try match with SURFMatching
[12:00:51][DEBUG]<airtest.aircv.keypoint_base> find_best_result() run time is 0.26 s.
[12:00:51][DEBUG]<airtest.core.api> try match with TemplateMatching
[12:00:51][DEBUG]<airtest.aircv.template_matching> [Template] threshold=0.6, result={'result': (1254, 166), 'rectangle': ((1222, 151), (1222, 182), (1287, 182), (1287, 151)), 'confidence': 0.9992009401321411}
[12:00:51][DEBUG]<airtest.aircv.template_matching> find_best_result() run time is 0.04 s.
[12:00:51][DEBUG]<airtest.core.api> match result: {'result': (1254, 166), 'rectangle': ((1222, 151), (1222, 182), (1287, 182), (1287, 151)), 'confidence': 0.9992009401321411}
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
this is jpg path:
D:/Air_Test/logs\7c2609c6e2bde6a70ae8b909a4d8ad3f\1557979252.jpg
D:\Air_Test\AirtestIDE_2019-04-16_py3_win64\selenium\webdriver\remote\webdriver.py:1031: UserWarning: name used for saved screenshot does not match file type. It should end with a `.png` extension
  "type. It should end with a `.png` extension", UserWarning)
----------------------------------------------------------------------
Ran 1 test in 48.881s

OK
[Finished]


**相关截图**
![image](https://user-images.githubusercontent.com/13159966/57830498-e33a2c00-77e4-11e9-86b3-962c09ceb33d.png)
![image](https://user-images.githubusercontent.com/13159966/57830517-f4833880-77e4-11e9-9c59-17b503186cf1.png)
![image](https://user-images.githubusercontent.com/13159966/57830542-0664db80-77e5-11e9-90bf-4985cba1cb36.png)
![image](https://user-images.githubusercontent.com/13159966/57830585-20062300-77e5-11e9-883e-fac4524acea5.png)



**复现步骤**
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**预期效果**
见截图3,4


**python 版本:** `python3.6`

**airtest 版本:** `1.2.1`
> airtest版本通过`pip freeze`可以命令可以查到

**设备:**
 - 型号: Chrome浏览器(74.0.3729.131 正式版本 64位)
 - 系统: PC windows10系统
 - (别的信息)

**其他相关环境信息**
(其他运行环境,例如在linux ubuntu16.04上运行异常,在windows上正常。)

运行时走到driver = WebChrome()时

【操作】:
1、设置内设置了Chrome的路径
2、连接窗口
3、根据提示导入必要的引入
4、driver.get输入一个网址
5、运行

【结果】:
点击进行运行后走到driver = WebChrome()报错,如下所示:

ERROR: runTest (app.widgets.code_runner.ide_launcher.AirtestIDECase)

Traceback (most recent call last):
File "airtest\cli\runner.py", line 73, in runTest
File "site-packages\six.py", line 693, in reraise
File "airtest\cli\runner.py", line 70, in runTest
File "C:\Users\tuya\Desktop\web_UI\untitled.air\untitled.py", line 9, in
driver = WebChrome()
File "D:\ruanjian\Airtest\AirtestIDE-win-1.2.5\AirtestIDE\airtest_selenium\proxy.py", line 30, in init
service_log_path=service_log_path, desired_capabilities=desired_capabilities)
File "D:\ruanjian\Airtest\AirtestIDE-win-1.2.5\AirtestIDE\selenium\webdriver\chrome\webdriver.py", line 81, in init
desired_capabilities=desired_capabilities)
File "D:\ruanjian\Airtest\AirtestIDE-win-1.2.5\AirtestIDE\selenium\webdriver\remote\webdriver.py", line 157, in init
self.start_session(capabilities, browser_profile)
File "D:\ruanjian\Airtest\AirtestIDE-win-1.2.5\AirtestIDE\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "D:\ruanjian\Airtest\AirtestIDE-win-1.2.5\AirtestIDE\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "D:\ruanjian\Airtest\AirtestIDE-win-1.2.5\AirtestIDE\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 10.0.18363 x86_64)


Ran 1 test in 7.815s

备注,【源码如下】:
from airtest.core.api import *

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from airtest_selenium.proxy import WebChrome
driver = WebChrome()
driver.implicitly_wait(20)

auto_setup(file)
driver.get("chrome://new-tab-page/")

Airtest-Selenium测试web页面判断图像相关问题

在使用Airtest-Selenium测试Web页面时,若要判断一些弹窗提示,若发生弹窗关闭弹窗继续执行,由于弹窗结构经常迭代修改,不想通过selenium元素定位的方式,想通过识别图像的方式判断,手机端可以使用if exists(图像元素)来判断,但貌似web端无法用这个方法,想问下目前有什么解决方案么?

编写多个脚本怎么做能只启动一次浏览器运行所有

用命令行运行官方例子里的针对APP测试的多脚本运行器(https://github.com/dreamhighqiu/airtest_project),用脚本运行后每一个.air都要启动一次浏览器。
在Web测试的时候只需要运行一次浏览器然后都在这个浏览器里执行操作。

把初始化浏览器放到setUpClass()里报错如下:

ERROR: setUpClass (main.CustomAirtestCase)

Traceback (most recent call last):
File "runner.py", line 18, in setUpClass
self.scope["driver"] = driver
AttributeError: type object 'CustomAirtestCase' has no attribute 'scope'

Images are missing from custom html report for selenium project

Hello All
I am using the following format to run .air file from CLI for my selenium project.

@echo off

"C:\AirtestIDE\AirtestIDE" runner "(AIR FILE PATH)" --log "(PATH FOR FOLDER)"

C:\AirtestIDE\AirtestIDE reporter "AIR FILE PATH" --log_root "PATH FOR FOLDER" --outfile "PATH FOR FOLDER\log.html" --static_root C:\AirtestIDE\airtest\report --lang en

@Pause

thing is all images appear when I run from Airetest IDE and missing when I used CLI
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.