Complete the code to create a remote WebDriver session connecting to the Selenium Grid hub.
from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities driver = webdriver.Remote(command_executor='[1]', desired_capabilities=DesiredCapabilities.CHROME) driver.get('https://example.com') driver.quit()
The Selenium Grid hub URL usually runs on port 4444 with the path '/wd/hub'. This URL tells the Remote WebDriver where to send commands.
Complete the code to specify the browser as Firefox when creating a remote WebDriver.
from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities caps = DesiredCapabilities.[1] driver = webdriver.Remote(command_executor='http://localhost:4444/wd/hub', desired_capabilities=caps) driver.get('https://example.com') driver.quit()
To run tests on Firefox browser via Selenium Grid, use DesiredCapabilities.FIREFOX.
Fix the error in the code to correctly set the desired capabilities for running tests on Edge browser.
from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities caps = DesiredCapabilities.[1] driver = webdriver.Remote(command_executor='http://localhost:4444/wd/hub', desired_capabilities=caps) driver.get('https://example.com') driver.quit()
For Edge browser, the correct desired capability is DesiredCapabilities.EDGE.
Fill both blanks to create a remote WebDriver that connects to the Grid hub and uses Chrome browser capabilities.
from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities hub_url = '[1]' caps = DesiredCapabilities.[2] driver = webdriver.Remote(command_executor=hub_url, desired_capabilities=caps) driver.get('https://example.com') driver.quit()
The hub URL is usually 'http://localhost:4444/wd/hub' and the Chrome browser capability is 'CHROME'.
Fill all three blanks to create a remote WebDriver session with Firefox browser, connecting to the Grid hub, and then navigate to a URL.
from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities hub = '[1]' caps = DesiredCapabilities.[2] driver = webdriver.Remote(command_executor=hub, desired_capabilities=caps) driver.get('[3]') driver.quit()
The hub URL is 'http://localhost:4444/wd/hub', the browser capability for Firefox is 'FIREFOX', and the URL to open is 'https://example.com'.