Problem with desired_capabilities
Andrew-Usachev opened this issue · 3 comments
webdriver.remote no longer accepts desired_capabilities argument how to run tests on selenoid?
'Python': '3.12.0', 'Platform': 'Windows-10-10.0.19045-SP0', 'pytest': '7.4.4' 'selenium': '4.0.1'
selenium.webdriver.remote.webdriver.WebDriver
def init(self,
command_executor: str = "http://127.0.0.1:4444",
keep_alive: bool = True,
file_detector: Any = None,
options: BaseOptions | list[BaseOptions] | None = None) -> None
@Andrew-Usachev you should use W3C compatible classes like ChromeOptions
described in Selenium docs. https://www.selenium.dev/documentation/webdriver/browsers/chrome/
@vania-pooh Hi, thanks a lot for you feedback! I figured it myself. If anyone is interested, here is my version
def pytest_addoption(parser):
parser.addoption("--executor", action="store", default="localhost")
@pytest.fixture(params=["chrome", "firefox"])
def browser(request):
executor = request.config.getoption("--executor")
browser_name = request.param
if browser_name == "chrome":
options = webdriver.ChromeOptions()
options.set_capability("browserVersion", "120.0")
options.set_capability("selenoid:options", {"enableVNC": True})
options.set_capability("selenoid:options", {"screenResolution": "1280x1024x24"})
options.set_capability("selenoid:options", {"enableVideo": False})
elif browser_name == "firefox":
options = webdriver.FirefoxOptions()
options.set_capability("browserVersion", "120.0")
options.set_capability("selenoid:options", {"enableVNC": True})
options.set_capability("selenoid:options", {"screenResolution": "1280x1024x24"})
options.set_capability("selenoid:options", {"enableVideo": False})
driver = webdriver.Remote(
command_executor=f"http://{executor}:4444/wd/hub",
options=options,
)
yield driver
driver.quit()
@Andrew-Usachev glad to hear that it worked.