Bird
0
0

What will be the output when running this code snippet connected to a Selenium Grid Hub with one Chrome node available?

medium📝 Predict Output Q4 of 15
Selenium Python - Selenium Grid
What will be the output when running this code snippet connected to a Selenium Grid Hub with one Chrome node available?
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

remote_url = 'http://localhost:4444/wd/hub'
driver = webdriver.Remote(command_executor=remote_url, desired_capabilities=DesiredCapabilities.CHROME)
print(driver.capabilities['browserName'])
driver.quit()
Aedge
Bfirefox
CNoSuchSessionException
Dchrome
Step-by-Step Solution
Solution:
  1. Step 1: Analyze desired capabilities

    The code requests a Chrome browser from the Grid.
  2. Step 2: Check output of capabilities

    driver.capabilities['browserName'] returns the browser name assigned, which is 'chrome'.
  3. Final Answer:

    chrome -> Option D
  4. Quick Check:

    Requested browser = chrome [OK]
Quick Trick: DesiredCapabilities.CHROME returns 'chrome' browser [OK]
Common Mistakes:
  • Expecting 'firefox' when Chrome requested
  • Confusing capability keys
  • Assuming runtime error without node

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes