python - Python + Selenium Grid
问题描述
I managed to set up a Node + Hub on my own pc.
I have a file called run_parallel_test.py
that simply just creates a process to execute test scripts based on sys args, which are just browser configs with capabilities.
The command would be as follows:
python run_parallel_tests.py testrunner.py browsers.json
testrunner.py
is basically Python's unittest framework executing test suites.
The issue I am having is before, I was hooked with browser stack and not selenium grid, I was able to pass browser capabilities such as this:
[
{
"browser": "Chrome",
"browser_version": "71.0 beta",
"os": "Windows",
"os_version": "10",
"resolution": "1920x1080"
},
{
"browser": "Firefox",
"browser_version": "blah blah",
"os": "Windows",
"os_version": "10",
"resolution": "1920x1080"
}
]
Now with a grid, those capabilities no longer work, and I have created barebone capabilities to simply run my tests such as:
[
{
"browserName": "chrome",
"browser_version": "71.0 beta",
"platform": "WINDOWS"
},
{
"browserName": "firefox",
"browser_version": "64.0 beta",
"platform": "WINDOWS"
},
{
"browserName": "chrome",
"platform": "WINDOWS"
},
{
"browserName": "internet explorer",
"platform": "WINDOWS"
}
]
The issue is, I no longer can set the resolution etc via my JSON file config as I was before when using browser stack. Is there a way to set up the resolution?
I have checked: https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities I could not find the documentation for it. Maybe I am looking at the wrong place.
解决方案
您不能通过服务器/网格设置它,因为它们没有为您的浏览器设置容器以像浏览器堆栈一样运行。您需要通过set_window_size 命令在 python 代码中设置浏览器大小
推荐阅读
- angular - Angular Kendo Grid 使删除的主行的详细信息可见
- c - 如何在 C 中编写计时器函数?我尝试使用clock()函数
- javascript - 组合具有相同值/id 的对象并将总和添加到新对象
- python - 我有 12000 个已知 URL,用 Python 抓取它们的最快方法是什么?
- python - 将优势比公式应用于多个变量
- matlab - matlab:为绘图添加颜色维度
- r - 在 linux 中使用多个输入文件在多个文件上运行算法
- angular - Angular 7+ 如何防止查询参数特殊字符转换为十六进制代码?
- android - 为 Android 应用创建标题面板的最佳方法是什么?
- solr - Apache solr slave 在索引完成之前被复制