Skip to content

Instantly share code, notes, and snippets.

@wehappyfew
Last active February 10, 2016 08:04
Show Gist options
  • Save wehappyfew/3430d1aa044c8ebc3d52 to your computer and use it in GitHub Desktop.
Save wehappyfew/3430d1aa044c8ebc3d52 to your computer and use it in GitHub Desktop.
Fixture class example to run python tests on a Selenium Grid
class Fixtures_docker(unittest.TestCase):
def setUp(self, hub_ip="http://HUB_TP", hub_port=4444):
print "--Fixtures_docker in config.py trying to run on--: %s:%s"%(hub_ip, hub_port)
if platform.system() == 'Linux':
from pyvirtualdisplay import Display
self.display = Display(visible=0, size=(1024, 768))
self.display.start()
if browser == "Firefox":
self.wd = webdriver.Remote(
command_executor=hub_ip + ':' + str(hub_port) + '/wd/hub',
desired_capabilities={
#FIREFOX
"browserName" : "firefox",
# "maxInstances" : 10,
"seleniumProtocol": "WebDriver",
"platform" : "ANY",
"node" : hub_port
})
# for debugging purposes from local machine
elif browser == "Firefox" and os == "Windows":
self.wd = webdriver.Remote(
command_executor=hub_ip + ':' + str(hub_port) + '/wd/hub',
desired_capabilities={
# FIREFOX -> WINDOWS
# "firefox_binary":"C:\\firefox3\Firefox3.exe", # path to find another version of ff
"browserName" : "firefox",
#"version" : "3.0b3", # trying to run a specific ff version
"platform" : "WINDOWS",
"node" : hub_port,
"maxSession" : 5
})
self.wd.implicitly_wait(10)
def tearDown(self):
self.wd.quit()
if platform.system() == 'Linux':
self.display.stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment