Selenium Python test against Selenium grid created from SeleniumHQ Docker images
Asked Answered
B

1

3

In brief

How to run Python Selenium tests properly against Selenium Grid container created from SeleniumHQ Docker images?

I also asked on SeleniumHQ here https://github.com/SeleniumHQ/docker-selenium/issues/521

The error & log

Full details

I've tried this web search and similar search on our site and found none useful.

OK with standalone

I've succeeded in running this simple test against the standalone selenium grid for Chrome and Firefox

- start the grid view standalone grid create script

docker run -d -p 4445:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:3.4.0-einsteinium
docker run -d -p 4446:4444 --shm-size 2g selenium/standalone-firefox:3.4.0-einsteinium

- run test view standalone test

#!/usr/bin/env python2.7

SELENIUM_HUB_CH = 'http://localhost:4445/wd/hub' #hub created at file 's01b_start_selenium_standalone_grid.sh'
SELENIUM_HUB_FF = 'http://localhost:4446/wd/hub' #hub created at file 's01b_start_selenium_standalone_grid.sh'

#region webdriver loading
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driverCH = webdriver.Remote(
  command_executor=SELENIUM_HUB_CH,
  desired_capabilities=DesiredCapabilities.CHROME,
)
driverFF = webdriver.Remote(
  command_executor=SELENIUM_HUB_FF,
  desired_capabilities=DesiredCapabilities.FIREFOX,
)
#endregion webdriver loading

for driver in [driverCH, driverFF]:
  driver.get('http://www.google.com')
  print(driver.title)

But FAIL with hub+node grid

Though I failed to run that simple test against the hub+node selenium grid

- start the grid view hub+node creation script

docker run -d -p 4444:4444 --name selenium-hub selenium/hub:3.4.0-einsteinium
docker run -d --link selenium-hub:hub selenium/node-chrome:3.4.0-einsteinium
docker run -d --link selenium-hub:hub selenium/node-firefox:3.4.0-einsteinium

- run the test view simple test

#!/usr/bin/env python2.7

SELENIUM_HUB = 'http://localhost:4444/wd/hub'

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver = webdriver.Remote(
  command_executor=SELENIUM_HUB,
  desired_capabilities=DesiredCapabilities.CHROME,
)

driver.get('http://www.google.com')
print(driver.title)

The question

I am interested in testing against Selenium grid containers i.e. the hub+node container created from these Docker images.

Barter answered 16/7, 2017 at 10:26 Comment(0)
B
0

Thanks to lmtierney's answer on github on SeleniumHQ

I can confirm that my test works now after installing python selenium 3.3.1

pip uninstall selenium ; pip install selenium==3.3.1
Barter answered 17/7, 2017 at 7:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.