0% found this document useful (0 votes)
8 views6 pages

Lab Manual - Exp 10 (STA)

The lab manual outlines the process for multi-browser and cross-device testing, focusing on verifying web application functionality across different browsers and devices. It details the framework architecture, test design methodology, and provides code examples for running tests on various browsers and mobile devices. Key challenges include browser-specific rendering differences and cross-platform compatibility issues.

Uploaded by

sriharan0305
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views6 pages

Lab Manual - Exp 10 (STA)

The lab manual outlines the process for multi-browser and cross-device testing, focusing on verifying web application functionality across different browsers and devices. It details the framework architecture, test design methodology, and provides code examples for running tests on various browsers and mobile devices. Key challenges include browser-specific rendering differences and cross-platform compatibility issues.

Uploaded by

sriharan0305
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Lab Manual :- Exp 10

Aim :- Multi-Browser & Cross-Device Testing.

Theory:-

Core Concept: Multi-Browser Testing


Objective:
Verify web application functionality across different browsers/devices to ensure
consistent user experience.

Key Challenges:

Browser-specific rendering differences


Varying JavaScript implementations
Cross-platform compatibility issues

2. Framework Architecture
A. Component Diagram

┌─────────────────┐ ┌──────────────────┐
┌─────────────────────┐
│ Test Script │ ──> │ WebDriver Manager│ ──> │ Browser Executables │
└─────────────────┘ └──────────────────┘
└─────────────────────┘
│ ▲
▼ │
┌─────────────────┐ ┌──────────────────┐
┌─────────────────────┐
│ Test Execution │ ──> │ Browser Instance │ ──> │ Web Application │
└─────────────────┘ └──────────────────┘
└─────────────────────┘

B. Workflow
Initialization: WebDriver Manager downloads/installs correct browser drivers
Session Creation: Spawns browser instances with configured options
Test Execution: Runs defined test scenarios
Validation: Checks browser-specific behaviors
Reporting: Captures screenshots and test results
Cleanup: Safely terminates browser sessions

Test Design Methodology

A. Atomic Test Structure


Setup: Initialize browser with options
Execution: Navigate and interact with AUT
Verification: Assert expected outcomes
Reporting: Capture evidence
Teardown: Release resources

B. Cross-Browser Strategy
Approach​ Implementation​ Use Case
Sequential​ Loop through browsers​ Development debugging
Parallel​ ThreadPoolExecutor​ CI/CD pipelines
Cloud Browserstack/SauceLabs integration​ Enterprise testing

C. Result Validation Matrix


Check Type​ Example Verification​ Tools Used
Content​ assert "Product" in page_source​ Selenium WebDriver
Layout​ Visual comparison with baseline​ Pillow/OpenCV
Functionality​ Add-to-cart workflow validation​ pytest assertions
Code

from selenium import webdriver


from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.firefox.options import Options as FirefoxOptions
import pandas as pd

def run_test(browser_name):
"""Run a simple test on different browsers"""
results = []
driver = None

try:
if browser_name.lower() == "chrome":
options = ChromeOptions()
options.add_argument("--start-maximized")
# New service-based initialization
driver =
webdriver.Chrome(service=webdriver.chrome.service.Service(ChromeDriverMana
ger().install()),
options=options)

elif browser_name.lower() == "firefox":


options = FirefoxOptions()
options.add_argument("--start-maximized")
# New service-based initialization
driver =
webdriver.Firefox(service=webdriver.firefox.service.Service(GeckoDriverManager
().install()),
options=options)

else:
return pd.DataFrame({"Browser": [browser_name], "Status":
["Unsupported"], "Screenshot": [None]})

# Test steps
driver.get("https://www.demoblaze.com")
title_contains_store = "STORE" in driver.title
screenshot = f"{browser_name}_screenshot.png"
driver.save_screenshot(screenshot)

results.append({
"Browser": browser_name,
"Page Title Correct": title_contains_store,
"Screenshot": screenshot,
"Status": "PASS" if title_contains_store else "FAIL"
})

except Exception as e:
results.append({
"Browser": browser_name,
"Status": f"ERROR: {str(e)}",
"Screenshot": None
})

finally:
if driver:
driver.quit()

return pd.DataFrame(results)

# Run tests on multiple browsers


browsers = ["Chrome", "Firefox"] # Add "Edge" if needed
all_results = []

for browser in browsers:


all_results.append(run_test(browser))
# Combine results
final_report = pd.concat(all_results)
display(final_report)

Mobile Testing

from selenium.webdriver.chrome.options import Options


from selenium.webdriver.chrome.service import Service

def run_mobile_test(device_name):
chrome_options = Options()
chrome_options.add_experimental_option(
"mobileEmulation",
{"deviceName": device_name}
)

driver = webdriver.Chrome(
service=Service(ChromeDriverManager().install()),
options=chrome_options
)

try:
driver.get("https://www.demoblaze.com")
screenshot = f"{device_name.replace(' ', '_')}_mobile.png"
driver.save_screenshot(screenshot)

return {
"Device": device_name,
"Viewport": driver.get_window_size(),
"Screenshot": screenshot
}
finally:
driver.quit()

# Test on different devices


devices = ["iPhone X", "Pixel 5", "iPad Pro"]
mobile_results = []

for device in devices:


mobile_results.append(run_mobile_test(device))

pd.DataFrame(mobile_results)

You might also like