简体   繁体   English

如何使用 Pytest 实现跨浏览器测试

[英]How to acheive cross browser testing using Pytest

Can someone help me how to run cross browser testing using pytest.有人可以帮助我如何使用 pytest 运行跨浏览器测试。 Basically i want to run my testcases in chrome, firefox and edge parallely at once.基本上我想同时在 chrome、firefox 和边缘并行运行我的测试用例。 I was now able to run individually now but i want to run in all 3 browsers at once.我现在可以单独运行,但我想同时在所有 3 个浏览器中运行。 Please provide the steps to acheive this.请提供实现此目的的步骤。

You need to use Selenium with Selenium Python Api .您需要将SeleniumSelenium Python Z72664DC0959F3B0C04891F8C78ZA . You can create 3 instances of drivers, one for the browser, and run in the same computer, or you can setup a Selenium Grid in order to run the same code in different computers with different browser (for advanced users).您可以创建 3 个驱动程序实例,一个用于浏览器,并在同一台计算机上运行,或者您可以设置一个 Selenium 网格,以便在具有不同浏览器的不同计算机上运行相同的代码(对于高级用户)。

How to run parallel test cases: you can use pytst-xdist package for this.如何运行并行测试用例:您可以为此使用pytst-xdist package。 You first need to install pytest-xdist using pip install pytest-xdist After that, from your tests folder run pytest -n=2, this command will invoke two test cases parallelly in two separate browser, use n= to specify number of parallel browser you want to run.您首先需要使用 pip 安装 pytest-xdist 安装 pytest-xdist 之后,从您的测试文件夹中运行 pytest -n=2,此命令将在两个单独的浏览器中并行调用两个测试用例,使用 n= 指定并行浏览器的数量你想跑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM