Posts

How to identify broken links in Selenium WebDriver: Python Example

Here's an updated Selenium Python program that checks for both missing and invalid links: import requests from selenium import webdriver # Create a new instance of the Firefox driver driver = webdriver.Firefox() # Navigate to the web page you want to check driver.get( "http://www.example.com" ) # Find all the links on the page links = driver.find_elements_by_tag_name( "a" ) # Loop through each link and check if it is missing or invalid for link in links:     href = link.get_attribute( "href" )     if href is None or href == "" :         print ( "Missing link: " , link.text)     else :         response = requests.head(href)         if response.status_code >= 400 :             print ( "Invalid link: " , href) # Close the browser window driver.quit() This updated program still uses Selenium to navigate to the web page and find all the links. However, it also ...

How to identify broken links in Selenium WebDriver: Java Example

import java . net . HttpURLConnection ; import java . net . URL ; import java . util . List ; import org . openqa . selenium . By ; import org . openqa . selenium . WebDriver ; import org . openqa . selenium . WebElement ; import org . openqa . selenium . chrome . ChromeDriver ; public class App {     public static void main ( String [] args ) throws Exception {         System . setProperty ( "webdriver.chrome.driver" , "D: \\ ChromeDriver \\ chromedriver.exe" );         // Initialize the Chrome Driver         WebDriver driver = new ChromeDriver ();         System . out . println ( "Before openinig url" );         //Navigate to the webpage         driver . get ( "https://www.google.com" );         // Find All links on the page         List < WebElement > links = driver . findElements ( By . tagN...

Commonly used Unit Test Frameworks and Commands.

  Here's a comparison of some commonly used commands for JUnit, TestNG, PyTest, and Robot Framework for unit testing: Command JUnit TestNG PyTest Robot Framework Test Annotation @ Test @ Test @ pytest.mark.test N/A Test Suite @ RunWith(JUnit.class) N/A N/A All Tests will be written under this section *** Test Cases *** Test Grouping N/A @ Test(groups = "smoke") pytest.mark *** Test Cases *** [Tags] smoke Test Setup @ Before / @BeforeClass @ BeforeMethod / @ BeforeClass setup_method / setup_class *** Settings *** Test Setup [Setup] Suite Setup Test Teardown @ After / @ AfterClass @ AfterMethod / @ AfterClass teardown_method / teardown_class *** Settings *** Test Teardown [TearDown] Suite Teardown Assertions assertEquals / assertTrue / assertFalse assertEquals / assertTrue / assertFalse assert / assertEqual / assertTrue Should Be Equal / Should Be True / Should Be False / Should Be None Parameterization @ RunWith(Parameterized.class) / @ Parameter @ DataProvider @ pyt...

Unit Testing Frameworks.

Image
 Unit Testing Frameworks. What are unit testing Frameworks? Unit testing frameworks are software tools that provide a testing infrastructure to automate the execution of unit tests. They typically provide a set of APIs, libraries, and tools to help developers write, organize, and execute unit tests for their code. Unit testing frameworks help to automate the process of testing software by providing a way to write and run automated tests for small units of code, typically individual functions or methods. These tests are usually written by developers and are designed to ensure that each unit of code is working correctly and that the system as a whole is functioning properly. Some common features provided by unit testing frameworks include: Assertions - a set of functions or statements that allow developers to check whether expected values match actual values. Test runners - tools that run tests and report the results. Test fixtures - reusable code that sets up the environment for a s...

Set up Selenium and Java on Visual Studio

Image
 Setting up selenium on Visual Studio is similar to setting up on Eclipse editor. However, to run the java program, we need to import certain libraries. We need to follow a few more steps to get the Selenium/WebDriver code running on the VS Code. Installation is easy and simple. Setting up VS for Java. To create a Java project, write code and run the code, we need to install Java extension Pack to the Visual Studio.  To install it from VS marketplace, click the link  here .  This will redirect you to the following page. Click on the Install button.  Download ChromeDriver To interact with the Chrome Browser, you should have latest ChromeDriver on your system and it should be discoverable by WebDriver. Also, the ChromeDriver major version has to match with your Chrome browser version. I suggest  to use latest Chrome browser and corresponding ChromeDriver.  Please note that Chrome Browser and ChromeDriver both are different...

Configure PyCharm Editor to run the Robot framework.

  What is PyCharm? PyCharm  is a cross-platform IDE that provides consistent experience on the Windows, macOS, and Linux operating systems. PyCharm is available in three editions: Professional, Community, and Edu. The Community and Edu editions are open-source projects and they are free, but they have fewer features. PyCharm Edu provides courses and helps you learn programming with Python. The Professional edition is commercial, and provides an outstanding set of tools and features. For details, see the  editions comparison matrix PyCharm also run and  debug tests in the same way as other applications/IDE like Eclipse, Visual Studio or Visual Code, by running the run/debug configurations you have added. When doing so, it passes the specified test classes or methods to the test runner. To configure the Run options, we need to follow the following steps Benefits of running tests from PyCharm UI  improves productivity lot.  Easier to run eithe...

Import multiple tests in Zephyr test cycle

 There are many occasions when we as software testers, leads and managers have to import multiple tests into Zephyr test cycle or folder. Zephyr for Jira is the world’s most widely used test management solution. Zephyr supports three different options to add tests in test cycle or folder. Individually : With this option, user can select individual test(s) and add into test cycle. Via Search Filter : With this option, user can select different filters and add multiple tests in test cycle. Here user can select user defined saved JQL as a specific Filter too to import multiple test in Zephyr tests cycle. Multiple filters can also be selected. From Another Cycle : With this option, user can selects previously created test cycle and add tests into current test cycle. Even though Zephyr plugin provides these much options, many time user face difficulty to add tests into test cycle. Take example of user wants to add tests from user stories for specific component or from specific s...