如何在AWS设备场上加速硒测试? [英] How to speed up selenium tests on AWS device farm?

查看:87
本文介绍了如何在AWS设备场上加速硒测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python在AWS设备场上进行测试。似乎开始硒需要很长时间。这是我使用的代码:

I'm using Python for testing on AWS device farm. It seems that starting a selenium takes very very long. This is the code I use:

from time import time

from boto3 import client
from selenium import webdriver


def main():
    start = time()

    device_farm_client = client("devicefarm", region_name='us-west-2')

    test_grid_url_response = device_farm_client.create_test_grid_url(
        expiresInSeconds=666,
        projectArn="arn:aws:devicefarm:us-west-2:..."
    )

    driver = webdriver.Remote(
        command_executor=test_grid_url_response['url'],
        desired_capabilities=webdriver.DesiredCapabilities.CHROME,
    )

    driver.get('https://api.ipify.org')
    print(f"Your IP is: {driver.find_element_by_tag_name('pre').text}")

    driver.quit()

    print(f"took: {time() - start:.2f}")


if __name__ == '__main__':
    main()

输出:

Your IP is: 100.10.10.111
took: 99.89s

使用现有的硒集线器基础设施,不到2秒即可获得IP!

Using existing selenium-hub infrastructure the IP is obtained in less than 2 seconds!

如何从根本上减少时间?

Is there any way how to reduce the time radically?

推荐答案

要减少完整测试套件执行的总执行时间,请利用50个并发时间默认情况下,您无需支付任何会话费用。检查此链接。例如:

To reduce the overall execution time for complete test suite execution take advantage of the 50 concurrent sessions given you by default at no cost. Check this link. For eg:

让我们假设以下细节


  • 一个测试套件具有200个硒测试用例

  • 每个测试用例执行大约需要10秒

  • 一个AWS Device Farm Selenium会话需要大约60秒启动

然后我将通过每个会话运行4个测试用例的并发批处理将200个测试用例分为50个并发会话。

then I will divide my 200 test cases into 50 concurrent sessions by running concurrent batches of 4 test cases per session.

总执行时间=(启动每个会话60秒+启动所有50个并发会话的10秒,每秒5个会话的速率+ 4 * 10秒在每个会话中执行测试用例)= 60 + 10 + 40 = 110秒以完成完整的测试套件执行

WHEREAS

如果您是现有的selenium-hub基础设施,并且可以假设以下详细信息

If you are existing selenium-hub infrastructure and lets say following details are assumed


  • 200个硒测试用例执行

  • 2秒以开始会话

  • 假设最多可以运行10个并发会话

总执行时间= 2秒以启动每个会话+ 20 * 10秒以在每个会话中执行测试用例= 200 + 2 = 202秒以完成完整的测试套件执行

这篇关于如何在AWS设备场上加速硒测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆