top of page

learner'sBlog

Designing a Selenium-Java automation framework involves structuring the project with folders for tests, page objects, and utilities. Implement the Page Object Model (POM) to organize code, encapsulating web elements and actions in dedicated classes. Leverage TestNG or JUnit for test scripting, utilizing annotations and assertions for efficient test execution. Integrate the Selenium WebDriver for browser automation, initializing it within test scripts for interaction with web elements. Enhance the framework with utility functions to handle common tasks, fostering a modular and maintainable automation solution.




10 views0 comments

Developing a Selenium Python framework involves creating a structured project with folders for tests, page objects, and utilities. Implement the Page Object Model (POM) design pattern to organize code, encapsulating web page elements and actions within dedicated classes. Leverage the Pytest testing framework for clear and modular test script development, using fixtures for reusable setups. Integrate the Selenium WebDriver for browser automation, initializing it in test scripts for interaction with web elements. Enhance the framework with utility functions to handle common tasks, such as waiting, logging, and handling browser-specific actions, ensuring a scalable and maintainable automation solution.





12 views0 comments

Take Screen shot on Test Failure

# Import necessary libraries
import time
from selenium import webdriver
from selenium.webdriver.common.by import By

# Create a new instance of the Chrome WebDriver
driver = webdriver.Chrome()

# Open the first tab and navigate to a website
driver.get("https://the-internet.herokuapp.com/")

# Find the page title element using its tag name ("h1")
page_title = driver.find_element(By.TAG_NAME, "h1")

# Retrieve the text content of the page title
actual_message = page_title.text

# Highlight the page title element by changing its style temporarily
driver.execute_script("arguments[0].setAttribute('style','background:yellow; border: 2px solid red;');", page_title)

# Pause script execution for 3 seconds for visibility (optional)
time.sleep(3)

# Print the actual page title message
print(actual_message)

# Define the expected page title message
expected_message = "The Internet"

# Perform assertion to check if actual message matches expected message
if actual_message == expected_message:
    assert True
else:
    # Save a screenshot if assertion fails
    driver.save_screenshot(".\\Screenshots\\" + "title.png")
    assert False

5 views0 comments
bottom of page