0

I have the following requirement. I should be able to dynamically provide port number to the params to pass in

webdriver.remote.webdriver.WebDriver(<PARAMS HERE>)

I tried many combinations but unable to figure it out

command = "command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=webdriver.DesiredCapabilities.HTMLUNIT"
driver = webdriver.remote.webdriver.WebDriver(command)

I get the following error:

Traceback (most recent call last):
  File "sel2.py", line 38, in <module>
  driver = webdriver.remote.webdriver.WebDriver(command)

  File "/home/sysqe/my36project/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 134, in __init__
    raise WebDriverException("Desired Capabilities can't be None")
selenium.common.exceptions.WebDriverException: Message: Desired Capabilities can't be None

it should be able to interpolate the var command and put the params in the place.

Vidur Oberoi
  • 75
  • 1
  • 3
  • 12

1 Answers1

0

Something like this might work for the key word args:

command = {
    command_executor: 'http://127.0.0.1:4444/wd/hub', 
    desired_capabilities: webdriver.DesiredCapabilities.HTMLUNIT
}
driver = webdriver.remote.webdriver.WebDriver(**command)

see:

jmunsch
  • 22,771
  • 11
  • 93
  • 114