Bird
0
0

What will be the output of this code?

medium📝 query result Q5 of 15
Selenium Python - Advanced Patterns
What will be the output of this code? metrics = driver.execute_script('return window.performance.getEntriesByType("resource")') print(len(metrics)) Assuming the page loaded 5 resource files (images, scripts, etc.).
A0
B5
C1
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand getEntriesByType('resource')

    This returns a list of resource timing entries, one per loaded resource.
  2. Step 2: Count the number of resources loaded

    Since 5 resources loaded, len(metrics) will be 5.
  3. Final Answer:

    5 -> Option B
  4. Quick Check:

    Resource count = 5 entries [OK]
Quick Trick: getEntriesByType('resource') returns all loaded resources [OK]
Common Mistakes:
  • Expecting zero if no resources
  • Confusing with navigation entries
  • Assuming error on valid JS

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes