Test Overview
This test opens a web page using BrowserStack cloud platform with Selenium in Python. It verifies the page title to confirm the correct page loaded.
This test opens a web page using BrowserStack cloud platform with Selenium in Python. It verifies the page title to confirm the correct page loaded.
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 BrowserStackTest(unittest.TestCase): def setUp(self): desired_cap = { 'browserName': 'Chrome', 'browserVersion': 'latest', 'bstack:options': { 'os': 'Windows', 'osVersion': '11', 'local': False, 'seleniumVersion': '4.8.0' } } self.driver = webdriver.Remote( command_executor='https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub.browserstack.com/wd/hub', desired_capabilities=desired_cap ) def test_page_title(self): self.driver.get('https://example.com') WebDriverWait(self.driver, 10).until( EC.title_contains('Example Domain') ) self.assertEqual(self.driver.title, 'Example Domain') def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and sets up remote WebDriver with BrowserStack capabilities | Remote WebDriver session is created on BrowserStack cloud with Windows 11 and Chrome latest | - | PASS |
| 2 | Browser opens and navigates to 'https://example.com' | Browser window on cloud platform loads the Example Domain page | - | PASS |
| 3 | Waits until page title contains 'Example Domain' | Page title is 'Example Domain' | Title contains 'Example Domain' | PASS |
| 4 | Asserts that page title equals 'Example Domain' | Page title is exactly 'Example Domain' | self.assertEqual(driver.title, 'Example Domain') | PASS |
| 5 | Test tears down and closes the remote browser session | Browser session on BrowserStack is closed | - | PASS |