Posts

How to validate broken link on the webpage using playwright?

1) Handle broken links in Playwright, typically follow a three-step  1)  Extract all links from the page use a locator to find all anchor ( <a> ) tags and then extract their  href  attributes.   2) Filter out invalid or repetitive URL Use Set collection to automatically remove duplicate links and filter out non-HTTP links. 3)  Then verify each URL by sending an HTTP request to check its status code. 2. Implementation Playwright, JS/TS This script uses page.request.get() to check links.  instead navigating to each page. it only fetches the HTTP response without rendering the full UI. 3. Key Strategies for Robust Testing Soft Assertions: Use expect.soft(),  test continues to check the remaining validation even if previous validation. Ex :  if one link is broken (e.g., a 404) , it will continue checking another link. HEAD vs. GET: Use page.request.head() if you only need the status code; it is faster as it doesn't download the entire p...

Java Program Input - "Welcome1","round4","1st3","to2" => output - "Welcome1","to2","1st3","round4"

  import java.util.Arrays ; import java.util.Comparator ; import java.util.regex.Matcher ; import java.util.regex.Pattern ; public class sortingStringUsingLastChar { public static void main ( String [] args) { String [] inputArray = { "Welcome1" , "round4" , "1st3" , "to2" }; System . out .println( "Original Array: " + Arrays . toString ( inputArray )); // Sort the array using a custom comparator Arrays . sort ( inputArray , new NumericStringComparator()); System . out .println( "Sorted Array: " + Arrays . toString ( inputArray )); } /** * A custom Comparator for sorting alphanumeric strings by the integer value they contain. */ static class NumericStringComparator implements Comparator < String > { // Pattern to find the first sequence of digits in a string private static final Pattern intsOnly = Pattern . compile ( " \\ d+ " ); ...

Java Program to remove duplicate char from String,

package RemoveDuplicaeCharFromSttring ; import java.util.LinkedHashSet ; import java.util.Set ; public class RemoveDuplicateCharFromString { public static String removeDuplicateCharsFromSring ( String inputSring) { if (inputSring == null || inputSring.isEmpty()) { return inputSring; } // A LinkedHashSet stores unique characters and maintains insertion order. Set < Character > seen = new LinkedHashSet<>(); // Use a StringBuilder for efficient string building. StringBuilder result = new StringBuilder(); // Iterate through the input string for ( char ch : inputSring.toCharArray()) { // If the character is not already in the set, add it to both the set and the result string if ( seen .add( ch )) { result .append( ch ); } } // Convert the StringBuilder to a String and re...

What is System.exit() in JAVA ?

  In Java,  System.exit()  is a command used to immediately shut down the running program. Think of it like a  "Kill Switch"  or an emergency exit button for your code. Once this line is reached, the program stops everything it is doing and closes, even if there is more code left to run. How it Works When you call  System.exit(n) , you must provide an integer (usually  0  or  1 ) inside the parentheses. This is called a  Status Code :   System.exit(0) : Tells the computer, "The program finished successfully with no problems. System.exit(1)  (or any non-zero number): Tells the computer, "The program crashed or stopped because of an error. Layman's Example: The ATM Imagine you are writing code for an ATM machine. The user inserts a card. The user enters the wrong PIN three times. For security, you want the program to  stop immediately  so no one can try a fourth time. Example: if (failedAttempts == 5 ) { System.out...

10 Best Way to Reverse a String in Java.

Image
  1) Using StringBuilder public class StringReverseUsingStringBuilder { public static void main ( String args[]){ String reversed = new StringBuilder(str).reverse().toString(); System . out .println( "Reversed String :" + reversed ); } } 2) Using StringBuffer Thread-safe alternative to StringBuilder. public class StringReverseUsingStringBuffer { public static void main ( String args[]){ String str = "Hello World" ; String reversed = new StringBuffer( str ).reverse().toString(); System . out .println( "Reversed string:" + reversed ); } } 3) Using Char Array Swapping (Optimized Manual Logic) public class ReserseUsingCharArraySwapping { public static void main ( String args[]){ String str = "Hello World" ; char [] arr = str .toCharArray(); int left= 0 ; int right= arr . length - 1 ; while (left<right){ char temp = arr [left]; ...

GenAI in QA Automation: Game Changer or Just Hype?

Will GenAI Be Successful for Software QA Automation in the Future? Software testing has already evolved from manual execution to automated scripting. Now the industry is entering a new era— Generative AI (GenAI) for QA automation . Many testers and developers are asking the same question: Will GenAI really work for software QA automation in the future? Below is a clear answer based on real trends, practical expectations, and future possibilities. What GenAI Can Do Today in QA Automation GenAI tools can already: create test cases from requirements write automation scripts from plain language fix locator issues automatically analyze failure reports suggest test improvements This means less manual effort and faster delivery. Will GenAI Generate Accurate Automation Code Without Human Help? Partly yes, partly no. ✔️ GenAI can generate working Playwright, Selenium, or API scripts. ✔️ It can learn patterns and fix common errors. ✔️ It will reduce human effort by 60–80%. But...

How to choose the right QA Automation tool for your web application?

"Selecting the right QA automation tool can make or break your testing strategy. " With so many options- Selenium, Cypress, Playwright, TestCafe etc. -- it's important to align the tool with your webpage's technology stack, team skills, and project goals.  Best Approach to Identify the Suitable Tool 1. Analyze Your Web Application Tech stack: Is it built on React, Angular, Vue, or plain HTML/CSS? Complexity: Does it have dynamic elements, heavy DOM manipulation, or SPAs? Browser Support: Do You need cross-browser testing or just Chrome? 2. Define Your testing Needs Functional Testing: UI workflows, form validations. Performance Testing: Page load, responsiveness. Integration with CI/CD: Jenkins, Azure DevOps, GitHub Actions. Reporting & Analytics: Do you need detailed dashboards? 3. Evaluate Tools Based on Key Criteria Criteria    Language Support             Why It Matters     Matches your team's skills (JS, Pyth...