Challenge - 5 Problems
HTML Report Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Selenium HTML report generation snippet
What will be the output status in the generated HTML report after running this Selenium test code snippet?
Selenium Python
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC import unittest from HtmlTestRunner import HTMLTestRunner class TestGoogleSearch(unittest.TestCase): def setUp(self): options = Options() options.add_argument('--headless') self.driver = webdriver.Chrome(options=options) def test_search(self): self.driver.get('https://www.google.com') search_box = self.driver.find_element(By.NAME, 'q') search_box.send_keys('OpenAI') search_box.submit() WebDriverWait(self.driver, 10).until( EC.title_contains('OpenAI') ) self.assertIn('OpenAI', self.driver.title) def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main(testRunner=HTMLTestRunner(output='reports'))
Attempts:
2 left
💡 Hint
Check if the locator and wait condition match the page behavior and if the HTMLTestRunner output folder is specified.
✗ Incorrect
The code correctly locates the search box by name 'q', waits for the page title to contain 'OpenAI', and asserts the title. The HTMLTestRunner generates a report in the 'reports' folder showing one passed test.
❓ assertion
intermediate1:30remaining
Correct assertion for verifying HTML report content
Which assertion correctly verifies that the generated HTML report contains the text 'Tests run: 1' indicating one test was executed?
Selenium Python
with open('reports/TestGoogleSearch.html', 'r', encoding='utf-8') as report_file: report_content = report_file.read()
Attempts:
2 left
💡 Hint
Use Python's 'in' keyword to check substring presence.
✗ Incorrect
The 'in' keyword checks if the substring exists in the string and returns True or False, which is suitable for assert. The other options either use invalid methods or check for absence.
❓ locator
advanced1:30remaining
Best locator strategy for report download button in Selenium
You want to automate clicking a 'Download Report' button in the HTML report page. The button has the text 'Download Report' and a unique id 'download-btn'. Which locator is the best practice to use in Selenium for this button?
Attempts:
2 left
💡 Hint
ID selectors are unique and fastest for locating elements.
✗ Incorrect
Using By.ID is the fastest and most reliable locator if the element has a unique id. XPath and CSS selectors work but are slower or more complex. Class name may not be unique.
🔧 Debug
advanced2:00remaining
Debugging missing HTML report generation
A Selenium test run with HTMLTestRunner does not generate any HTML report files. Which is the most likely cause?
Attempts:
2 left
💡 Hint
Check if the output directory exists before running tests.
✗ Incorrect
HTMLTestRunner requires the output directory to exist; it does not create it automatically. If the folder is missing, no report files are saved. Syntax errors or missing test runner calls cause different failures. Test method naming affects test discovery but not report generation if tests run.
❓ framework
expert3:00remaining
Configuring parallel test execution with HTML report generation
You want to run multiple Selenium tests in parallel using unittest and generate a single consolidated HTML report. Which approach is correct?
Attempts:
2 left
💡 Hint
Consider limitations of unittest and HTMLTestRunner with parallel execution.
✗ Incorrect
unittest and HTMLTestRunner do not support merging reports from parallel runs automatically. Using pytest with xdist allows parallel runs and generating separate reports, which can be merged with additional tools. Running sequentially avoids conflicts but loses parallelism. Custom threading and merging is complex and error-prone.