0
0
Selenium Pythontesting~10 mins

Grid setup and configuration in Selenium Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to connect to the Selenium Grid hub.

Selenium Python
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

hub = webdriver.Remote(command_executor='http://localhost:4444/wd/hub', desired_capabilities=[1])

hub.quit()
Drag options to blanks, or click blank then click option'
ADesiredCapabilities.FIREFOX
BDesiredCapabilities.SAFARI
CDesiredCapabilities.CHROME
DDesiredCapabilities.EDGE
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong DesiredCapabilities value that does not match the node's browser.
Forgetting to specify desired_capabilities parameter.
2fill in blank
medium

Complete the code to register a node to the Selenium Grid hub using command line.

Selenium Python
java -jar selenium-server-standalone.jar -role node -hub http://localhost:4444/grid/register -port [1]
Drag options to blanks, or click blank then click option'
A5555
B4444
C8080
D5554
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same port as the hub (4444) for the node.
Choosing a port that is already in use.
3fill in blank
hard

Fix the error in the node configuration JSON to specify the correct browser name.

Selenium Python
{
  "capabilities": [
    {
      "browserName": "[1]",
      "maxInstances": 5
    }
  ],
  "configuration": {
    "port": 5555,
    "hub": "http://localhost:4444/grid/register"
  }
}
Drag options to blanks, or click blank then click option'
Ainternet explorer
Bchrome
Cfirefox
Dsafari
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase or incorrect browser names.
Using browser names that do not match installed browsers on the node.
4fill in blank
hard

Fill both blanks to create a Python test that connects to the Selenium Grid hub and opens a webpage.

Selenium Python
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

browser = webdriver.Remote(command_executor='http://localhost:4444/wd/hub', desired_capabilities=[1])
browser.get([2])
browser.quit()
Drag options to blanks, or click blank then click option'
ADesiredCapabilities.FIREFOX
B"https://example.com"
CDesiredCapabilities.CHROME
D"http://localhost"
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing browser capabilities and URL values.
Forgetting to put quotes around the URL.
5fill in blank
hard

Fill all three blanks to create a Python dictionary comprehension that filters nodes by maxInstances and browserName.

Selenium Python
filtered_nodes = {node['id']: node for node in nodes if node['maxInstances'] [1] 3 and node['browserName'] == [2] and node['status'] == [3]
Drag options to blanks, or click blank then click option'
A>
B"chrome"
C"active"
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators like < instead of >.
Forgetting quotes around string values.
Mixing up the order of conditions.