0
0
Selenium Pythontesting~10 mins

Why CI integration enables continuous testing in Selenium Python - Test Execution Impact

Choose your learning style9 modes available
Test Overview

This test simulates a simple Selenium test running as part of a Continuous Integration (CI) pipeline. It verifies that the login button is present and clickable on the homepage, demonstrating how CI integration allows automated tests to run continuously on code changes.

Test Code - unittest
Selenium Python
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import unittest

class TestLoginButton(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://example.com')

    def test_login_button_clickable(self):
        wait = WebDriverWait(self.driver, 10)
        login_button = wait.until(EC.element_to_be_clickable((By.ID, 'login-btn')))
        self.assertTrue(login_button.is_enabled())

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

if __name__ == '__main__':
    unittest.main()
Execution Trace - 7 Steps
StepActionSystem StateAssertionResult
1Test startsTest framework initializes and prepares to run tests-PASS
2Browser opens ChromeChrome browser window opens and is ready-PASS
3Navigates to 'https://example.com'Homepage of example.com loads in browser-PASS
4Waits up to 10 seconds for element with ID 'login-btn' to be clickableLogin button is visible and enabled on the pageCheck if login button is enabled (clickable)PASS
5Assertion checks login button is enabledLogin button is confirmed clickableassertTrue(login_button.is_enabled())PASS
6Browser closesChrome browser window closes-PASS
7Test ends with all assertions passingTest framework reports success-PASS
Failure Scenario
Failing Condition: Login button with ID 'login-btn' is not found or not clickable within 10 seconds
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify on the webpage?
AThe user can log in successfully
BThe page title is correct
CThe login button is clickable
DThe homepage loads within 5 seconds
Key Result
Integrating tests like this into a CI pipeline allows automated checks to run on every code change, catching issues early and enabling continuous testing.