0
0
Selenium Pythontesting~10 mins

WebDriver setup (ChromeDriver, GeckoDriver) in Selenium Python - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test opens a browser using Selenium WebDriver with ChromeDriver, navigates to a simple page, and verifies the page title to confirm the setup works correctly.

Test Code - unittest
Selenium Python
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import unittest

class TestWebDriverSetup(unittest.TestCase):
    def setUp(self):
        service = Service(executable_path='chromedriver')
        self.driver = webdriver.Chrome(service=service)

    def test_open_google(self):
        self.driver.get('https://www.google.com')
        title = self.driver.title
        self.assertEqual(title, 'Google')

    def tearDown(self):
        self.driver.quit()

if __name__ == '__main__':
    unittest.main()
Execution Trace - 4 Steps
StepActionSystem StateAssertionResult
1Test starts and setUp method runsChromeDriver executable is located and Chrome browser instance is launched-PASS
2Browser navigates to 'https://www.google.com'Browser window shows Google homepage-PASS
3Test retrieves page titlePage title is 'Google'Assert page title equals 'Google'PASS
4tearDown method runs and browser closesBrowser window is closed, WebDriver session ends-PASS
Failure Scenario
Failing Condition: ChromeDriver executable path is incorrect or ChromeDriver is not installed
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify after opening the browser?
AThe page title is 'Google'
BThe browser URL is 'https://www.google.com/search'
CThe browser window size is 1024x768
DThe page contains a search input field
Key Result
Always verify that the WebDriver executable path is correct and compatible with the browser version to avoid setup failures.