首页 > 解决方案 > 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.

标签: pythonseleniumselenium-webdriverselenium-grid

解决方案


您不能通过服务器/网格设置它,因为它们没有为您的浏览器设置容器以像浏览器堆栈一样运行。您需要通过set_window_size 命令在 python 代码中设置浏览器大小


推荐阅读