TESTEVERYTHING

Showing posts with label Automation. Show all posts
Showing posts with label Automation. Show all posts

Tuesday, 13 October 2026

 Windows automation guide

How to Set Up Playwright on Windows

A practical, step-by-step path from installing Node.js to running your first cross-browser automated test.

Introduction

Playwright is a modern end-to-end testing and browser automation framework built by Microsoft. It supports Chromium, Firefox, and WebKit through a single API, making cross-browser testing faster and more reliable.

If you’re a QA engineer, developer, or automation enthusiast using Windows, this guide covers everything you need to get Playwright running—from installing prerequisites to executing your first automated test script.

What you’ll have at the end: a functional Playwright environment on Windows and a working test example you can build on.

Prerequisites

  • A Windows 10 or Windows 11 machine
  • Administrator access to install software
  • A stable internet connection for browser binaries
  • A code editor such as Visual Studio Code (recommended)

Step-by-step setup

1. Install Node.js

Playwright runs on Node.js. Visit nodejs.org, download the Windows LTS release, and run the .msi installer with the default options.

Verify the installation in Command Prompt or PowerShell:

node -v
npm -v

If both commands return version numbers, Node.js and npm are ready.

2. Install Visual Studio Code

VS Code is optional, but its Playwright Test extension provides convenient test running and debugging. Download it from code.visualstudio.com, then install the Playwright Test for VSCode extension from the Extensions Marketplace.

3. Create a project folder

mkdir playwright-demo
cd playwright-demo

4. Initialize a Node.js project

npm init -y

This creates a package.json file for managing project dependencies.

5. Install Playwright

npm init playwright@latest

Choose your preferences when prompted:

  • Language: TypeScript is recommended, though JavaScript is supported.
  • Test folder: The default tests folder is a good choice.
  • GitHub Actions: Optional, and useful for CI/CD.
  • Browsers: Choose Yes to download them now.

The generated project will look like this:

playwright-demo/
├── tests/
│   └── example.spec.ts
├── playwright.config.ts
├── package.json
└── node_modules/

6. Verify browser installation

If browsers were not installed automatically, or you want to reinstall them, run:

npx playwright install

This downloads the Chromium, Firefox, and WebKit binaries needed for multi-browser testing.

7. Run your first test

npx playwright test

Playwright runs the generated sample test in headless mode and prints the results in your terminal.

8. View the HTML report

npx playwright show-report

The interactive report opens in your default browser and includes test steps, screenshots, traces, and execution timelines.

9. Run tests in headed mode

Watch browser actions in real time, or target one browser project:

npx playwright test --headed
npx playwright test --project=chromium

10. Write a custom test

Create tests/sample.spec.ts:

import { test, expect } from '@playwright/test';

test('has title', async ({ page }) => {
  await page.goto('https://playwright.dev/');
  await expect(page).toHaveTitle(/Playwright/);
});

Run the test with:

npx playwright test sample.spec.ts

If it passes, your Playwright environment is fully functional.

Common setup issues on Windows

IssuePossible causeSuggested fix
npx not recognizedNode.js is missing or not on PATHReinstall Node.js and ensure “Add to PATH” is checked.
Browsers fail to downloadFirewall or antivirus blocks downloadsCheck security software or run the terminal as Administrator.
Timeout errorsSlow network or incorrect selectorsIncrease the timeout in playwright.config.ts and verify selectors.
PowerShell scripts blockedExecution policy restrictionRun Set-ExecutionPolicy RemoteSigned -Scope CurrentUser in PowerShell (Admin).

Always check configuration changes and security-related commands against your organization’s IT policies.

Best practices after setup

  • Update Playwright and browser binaries with npm install -D @playwright/test@latest, followed by npx playwright install.
  • Use the Trace Viewer with npx playwright show-trace to debug failures.
  • Organize larger test suites using the Page Object Model (POM).
  • Integrate with GitHub Actions, Jenkins, or Azure DevOps for CI/CD.

Conclusion

Once Node.js is installed, setting up Playwright on Windows takes only a few commands. You now have multi-browser support, rich reporting, and powerful debugging tools ready for your automation work.

Take your test automation further

Subscribe for more Playwright tutorials, best practices, and real-world automation strategies delivered to your inbox.

FAQs

Does Playwright work on Windows 11?Yes. Playwright supports both Windows 10 and Windows 11.
Do I need to install browsers separately?No. The setup flow can download them automatically; use npx playwright install when needed.
Can I use JavaScript instead of TypeScript?Yes. Playwright supports both JavaScript and TypeScript.
Is Playwright free?Yes. It is an open-source framework maintained by Microsoft.
How do I update Playwright?Run npm install -D @playwright/test@latest, followed by npx playwright install.

Wednesday, 23 September 2026

Top 5 Best AI Tools for Automation Testing

Top 5 Best AI Tools for Automation Testing (2025)
2025 comparison guide · QA & automation

Top 5 AI tools for automation testing

A practical, side-by-side look at the platforms making test suites more resilient, more accessible, and easier to scale.

12 min readEnterprise & growth teams

Less firefighting.
More confidence.

Traditional test automation has a familiar Achilles’ heel: scripts break the moment a UI element shifts, a button gets renamed, or a workflow changes. As release cycles accelerate, QA teams can’t afford to spend hours maintaining flaky tests.

AI-powered automation testing combines machine learning, NLP, and computer vision to introduce self-healing scripts, codeless authoring, autonomous test generation, and smarter failure triage.

What “AI-powered” means in testing

The best platforms don’t just record clicks. They help teams author, run, understand, and maintain tests across the entire delivery lifecycle.

⌁
Self-healing locators

Adapt to UI changes and update broken element references.

✎
NLP authoring

Create test cases with natural language or visual recorders.

✦
Test generation

Turn user flows and requirements into executable coverage.

◉
Smart triage

Separate genuine bugs from flaky tests and environment issues.

↗
CI/CD native

Connect quality gates to your existing delivery pipelines.

The shortlist

Five tools worth testing

Each platform solves a different bottleneck. The right choice depends on your stack, skills, and governance needs.

01
Enterprise packaged apps

ACCELQ

ACCELQ is a codeless, model-based platform for complex, multi-system landscapes. It pairs broad surface coverage with purpose-built support for Salesforce, SAP, and Oracle.

AI capabilities

  • Natural-language, zero-script authoring
  • Change Bot and Smart View Analyzer self-healing
  • Generative AI “Autopilot” for faster creation

Strengths

  • Best-in-class packaged-app support
  • Web, API, mobile, desktop, mainframe

Watch-outs

  • Steeper learning curve for code-first teams
  • Enterprise pricing and vendor lock-in

Pricing: Custom, quote-based, per-seat licensing.
Best for: Large Salesforce, SAP, or Oracle environments.

02
Web-first analytics

mabl

mabl is an AI-native, web-focused platform built for speed. Low-code creation sits alongside deep analytics and coverage for API, accessibility, and performance testing.

AI capabilities

  • Auto-healing and agentic runtime recovery
  • Visual assertions and heal-review diffs
  • AI-assisted test generation

Strengths

  • Unlimited local and CI runs
  • Strong Datadog and PagerDuty analytics

Watch-outs

  • Mobile is an add-on
  • Credit-based forecasting can be complex

Pricing: Custom; around 500 credits/month, 14-day trial.
Best for: Web-first teams that need analytics at scale.

03
Developer-led QA

Testim

Now part of Tricentis, Testim uses Smart Locators to fingerprint UI elements across multiple attributes. Tests can be edited visually or exported as real code.

AI capabilities

  • Multi-attribute Smart Locators
  • Chrome recorder with visual editor
  • IDE integration and Tricentis alignment

Strengths

  • Excellent developer experience
  • Broad CI/CD integrations

Watch-outs

  • Less automated failure classification
  • Execution pricing scales with volume

Pricing: Typically $500–$1,000/month starter; Community tier available.
Best for: Developer-led teams in the Tricentis ecosystem.

04
Plain-English testing

Functionize

Functionize turns requirements and user stories into executable steps through NLP. Its multi-modal AI supports visual, cross-browser, mobile, and performance workflows.

AI capabilities

  • Plain-English test authoring
  • Self-healing with optional RCA tools
  • Cloud-scale execution using user behavior data

Strengths

  • Lowest technical barrier
  • Strong BDD workflow support

Watch-outs

  • Custom enterprise pricing
  • Heals typically need QA approval

Pricing: Enterprise-oriented, custom quotes.
Best for: Non-technical authors and BDD-heavy teams.

05
All-in-one coverage

Katalon

Katalon is a versatile generalist spanning web, native mobile, API, and desktop testing. TestOps adds centralized test management and reporting for teams that want one platform.

AI capabilities

  • AI-assisted generation and self-healing
  • Centralized reporting with TestOps
  • Native Jira traceability

Strengths

  • Broad out-of-the-box coverage
  • Strong community and docs

Watch-outs

  • Less specialized self-healing
  • Packaged-app support trails ACCELQ

Pricing: Entry plans around $208–$500/month.
Best for: Teams needing web, mobile, API, and desktop together.

At a glance

Compare the contenders

ToolCoverageStandout AIBest forStarting price
ACCELQWeb, API, mobile, desktop, mainframe, Salesforce/SAP/OracleAutopilot + Change BotPackaged-app enterprisesCustom
mablWeb, API, accessibility, performanceAgentic recovery + heal reviewAnalytics-led web teamsCustom / credits
TestimWeb, API; mobile via partnersSmart LocatorsDevelopers / Tricentis shops~$500–$1,000/mo
FunctionizeWeb, mobile, performanceNLP test authoringNon-technical authorsCustom
KatalonWeb, mobile, API, desktopAI generation + TestOpsAll-in-one coverage~$208–$500/mo
Make the decision measurable

Choose with your stack, not the hype.

A short, focused pilot reveals more than a feature checklist. Put the same suite through two shortlisted tools and measure the operational impact.

Map your ecosystem

Salesforce, SAP, or Oracle points to ACCELQ. Tricentis users should evaluate Testim. For broad web, mobile, API, and desktop coverage, start with Katalon.

Match the author

Developer-heavy teams may prefer Testim. Business testers may thrive with Functionize. Mixed-skill teams can look to ACCELQ or mabl.

Run a two-week pilot

Track flaky-test reduction, authoring and maintenance time, CI/CD integration ease, and total cost including seats, concurrency, and support.

Common questions

Before you commit

Do AI tools eliminate test maintenance?

No. Self-healing reduces maintenance significantly, but human oversight is still needed to validate healed tests and catch genuine regressions.

Are they suitable for small teams?

Yes. Katalon and Testim have relatively accessible entry points, while ACCELQ and Functionize generally target enterprise budgets.

Can they replace manual testing?

No. They accelerate regression and functional testing, while exploratory, usability, and edge-case testing still benefit from human judgment.

Who has the best CI/CD integration?

All five connect to major pipelines. mabl and Testim are especially frequently highlighted for smooth pipeline-native execution.

QualityStack / Testing intelligenceAI automation testing guide · 2026

Friday, 4 September 2026

How AI is Finally Fixing Our Worst API Testing Nightmares

Beyond Broken Endpoints: How AI is Finally Fixing Our Worst API Testing Nightmares

Beyond Broken Endpoints: How AI is Finally Fixing Our Worst API Testing Nightmares

If you’ve ever wanted to pull your hair out over a failing POST /users test at 4:45 PM on a Friday, you are in good company. API automation testing is supposed to be the "easy" part of the testing pyramid. No complex UI locators to break, no browser rendering issues to debug, just clean JSON payloads and predictable status codes. Except, it’s rarely that simple. In the real world, API automation is a constant battle against dynamic data, shifting schemas, and brittle test suites. But things are changing. AI is quietly stepping in to take over the tedious, repetitive parts of the job, turning API testing from a maintenance headache into something almost… effortless. Let’s look at the biggest pain points in API testing today, and how AI-powered tools (both free and paid) are solving them.


The Real-World Obstacles: Why API Testing Breaks

Before we look at the fixes, let’s be honest about what makes API automation so exhausting.

1. Schema Drift (The "Who Changed the JSON?" Problem)

You write a flawless suite of tests. Overnight, a developer updates a microservice and changes a response key from user_id to userId. Suddenly, fifty tests fail. The API still works, but your tests are dead in the water.

2. The Dynamic Data & Auth Token Chase

Managing dynamic states—like generating a fresh OAuth token, passing it to a helper function, grabbing an ID from a GET response, and feeding it into a DELETE request—requires a lot of boilerplate code. If one step timing-out or returning slightly different data occurs, the whole chain collapses.

3. Assertion Fatigue

Writing assertions is boring. To properly test an endpoint, you need to verify status codes, headers, response times, data types, and specific value ranges. Writing these manually for dozens of endpoints is a recipe for developer burnout, which often leads to cutting corners (e.g., only asserting status === 200 and calling it a day).


How AI Actually Helps (Without the Hype)

AI isn't going to replace the human understanding of business logic, but it is incredibly good at handling the heavy lifting of API testing.

  • Self-Healing Tests: When a field name changes slightly, AI can analyze the historical context of the payload, realize that userId is the same as the old user_id, update the test logic on the fly, and flag it for your review instead of failing the build.
  • Auto-Generating Payloads: Instead of manually writing mock JSON objects, you can feed an AI your API schema, and it will automatically generate edge-case payloads (like empty strings, SQL injection attempts, and massive integers) to stress-test your endpoints.
  • Automated Assertions: Instead of writing twenty lines of assertion code, you can ask an AI assistant to analyze a sample response and write the assertion block for you in seconds.

The Toolbox: Paid vs. Free AI Testing Tools

If you want to start leveraging AI for your API testing, you don't need a massive budget. Here is a breakdown of the best tools currently available.

The Paid Heavy Hitters

These platforms are built for teams and enterprise workflows, offering robust, out-of-the-box AI integrations.

1. Postman (with Postbot)

  • What it is: Postman is already the industry standard for API development, but its built-in AI assistant, Postbot, takes it to the next level.
  • How it helps: You can highlight a response payload and tell Postbot in plain English: "Write tests to verify all fields are present and response time is under 200ms." It writes the JavaScript code instantly. It can also generate mock data and fix broken test scripts on the fly.
  • Pricing: Postbot is available as an add-on to Postman plans (starting at around $9/user/month), though there is a limited free tier to try it out.

2. Katalon Platform

  • What it is: A comprehensive quality management platform that combines UI, mobile, and API testing.
  • How it helps: Katalon uses AI to auto-generate test code from your API documentation (like Swagger/OpenAPI specs) and offers self-healing capabilities that prevent test suites from breaking when minor changes occur in API responses.
  • Pricing: Free tier available for basic use; premium plans start at $167/month for professional teams.

The Free and Open-Source Game Changers

If you prefer open-source software or are working with zero budget, these tools are incredibly powerful.

1. Keploy

  • What it is: An open-source, developer-focused API testing tool that uses AI/ML to automate the entire test generation process.
  • How it helps: Keploy runs in the background while you run your application. It records actual API traffic (including database calls and external dependencies) and automatically generates test cases and mocks. It completely bypasses the need to write manual boilerplate API test code.
  • Pricing: 100% Free and Open Source.

2. Local AI + Playwright / REST Assured (The DIY Route)

  • What it is: Running a local, open-source Large Language Model (like Llama 3 via Ollama) directly on your machine.
  • How it helps: If your company has strict data privacy rules and won't let you send API payloads to external servers (like OpenAI), you can use a local LLM. You can feed your Swagger file or API controller code into the local model and ask it to: "Generate a complete suite of Playwright API tests covering positive, negative, and boundary cases."
  • Pricing: Completely free.

The Verdict: Don't Code Harder, Code Smarter

API testing doesn't have to be a repetitive cycle of fixing broken assertions and updating outdated mocks. The smartest approach today is a hybrid one. Let AI write the boilerplate code, generate your edge-case payloads, and draft your assertions. Save your brainpower for the high-level architecture: designing the integration flows, understanding the security implications, and ensuring the business logic actually makes sense.

Have you started using AI in your API testing pipeline yet? What’s your go-to tool? Let me know in the comments below!

Thursday, 20 August 2026

Top 10 YouTube channels for AI testing and QA automation

 The top 10 YouTube channels for AI testing and QA automation include a mix of dedicated software quality assurance (QA) creators, specialized platforms, and core engineering hubs that focus heavily on evaluating, validating, and testing artificial intelligence models

YouTube creators do not usually share personal phone numbers or direct personal email addresses on public profiles to prevent spam. Instead, you can reach out to them via their official websites, business contact forms, or primary professional networks

Top 10 YouTube Channels for AI Testing

#Channel NameCore Focus in AI Testing & AutomationChannel URLPrimary Contact / Verification Method
1Naveen AutomationLabsDeep dives into Agentic AI for software testing, modern QA tools, and building smart automation workflows.Naveen AutomationLabsContact via Naveen AutomationLabs Website
2Automation Step by StepStep-by-step beginner guides for applying AI within software testing framework design and implementation.Automation Step by StepContact via Automation Step by Step Platform
3The Testing AcademyComprehensive series on AI tools every QA tester must learn, LLM validation, and test optimization.The Testing AcademyContact via The Testing Academy Official Site
4LambdaTestIndustry webinars and execution guides on AI-driven cross-browser visual testing and test intelligence.LambdaTestContact via LambdaTest Business Support
5Software Testing by Daniel KnottHands-on reviews focusing directly on free and premium AI testing applications and automation practices.Daniel Knott QAContact via Daniel Knott Blog & Portal
6Matthew BermanRigorous hands-on benchmarking and systematic testing of new large language models (LLMs) and local AI agent tools.Matthew BermanContact via Matthew Berman on LinkedIn
7DeepLearning.AIFounded by Andrew Ng; critical for understanding fundamental evaluations, prompt testing, and AI agent validation layers.DeepLearning.AIContact via DeepLearning.AI Contact Form
8Automate With AmitPractical tutorials showcasing how to use AI-powered assistant extensions and smart tools for functional testing.Automate With AmitContact via business queries on his YouTube 'About' page.
9SDET - QA Automation TechieTechnical execution pathways for shifting from standard API automation into AI-based test suites and validations.SDET TechieContact via business inquiries on his YouTube portal.
10Andrej KarpathyEssential masterclasses for learning how to build and evaluate neural network models from the ground up.Andrej KarpathyContact via Andrej Karpathy GitHub Profile

Saturday, 17 May 2025

How to handle new tab using playwright

 

Scenario:

You click a link or button that opens a new tab, and you want to switch to that tab and perform actions.



  const [newPage] = await Promise.all([

    context.waitForEvent('page'),         // Waits for a new tab to be opened

    page.click('a[target="_blank"]'),     // Simulates clicking the link that opens a new tab

  ]);


  // Wait for the new tab to load

  await newPage.waitForLoadState();


  // Do something in the new tab

  console.log('New tab title:', await newPage.title());


  // Example: take screenshot of the new tab

  await newPage.screenshot({ path: 'new-tab.png' });


  await browser.close();

})();


Key Concepts:

  • context.waitForEvent('page'): Waits for a new tab or popup.

  • The Promise.all() ensures that the event and click happen together.

  • newPage.waitForLoadState(): Ensures the new tab is fully loaded before interaction.


Monday, 26 November 2018

Selenium 4 Release / Webdriver latest release

Selenium 4 is all set to release this Christmas. Simon Stewart (a founding member of Selenium) officially announced it at the recently held Selenium conference in Bangalore. Some major changes in the upcoming Selenium version 4 have been revealed. It’s time to get ahead of the curve and figure out what is going to be changed, added, and deprecated. In this article, we will take a look at a few important features and give some insight on updates you can expect for your automation framework.

W3C WebDriver Standardization

The Selenium 4 WebDriver will be completely W3C Standardized. The WebDriver API has grown to be relevant outside of Selenium. It is used in multiple tools for automation. For example, it’s used heavily in mobile testing through tools such as Appium and iOS Driver. The W3C standard will encourage compatibility across different software implementations of the WebDriver API.
Let’s take an example of how Selenium Grid communicates with Driver executables as of now –

Adopting New Protocol

Adopting-New-Protocol
A test in Selenium 3.x, on the local end (through JSON wire protocol) communicates with the browser at the End node. This requires encoding and decoding of the API. In Selenium 4, the test will directly communicate without any encoding and decoding of API requests (through the W3C Protocol), though Java bindings will be backward-compatible, but focusing more on the W3C Protocol. The JSON wire protocol will no longer be used.
There are multiple contributors in the WebDriver W3C specs. All of the work done is on GitHub.

Selenium 4 IDE TNG

Selenium-4-IDE-TNG
Selenium IDE support for Chrome is in the bucket. As we all know, Selenium IDE is a record and playback tool. It will now be available with much richer and more advanced features, such as
  • New plugin system – Any browser vendor will now be able to easily plug in to the new Selenium IDE. You can have your own locator strategy and plug in the Selenium IDE.
  • New CLI runner – It will be completely based on node.js, not the old HTML-based runner. It will have the following capabilities:
    • WebDriver Playback – The new Selenium IDE runner will be completely based on WebDriver.
    • Parallel execution — The new CLI runner will also support parallel test case execution and will provide useful information like time taken and number of test cases passed/failed.

Improved Selenium Grid

Those who have worked with Selenium Grid know how difficult it is to set up and configure. Selenium Grid supports test case execution on different browsers, operating systems, and machines, providing parallel execution capability.
There are two main elements in Selenium Grid: Hub and  Node.
Hub acts as a server, a central point to control all the test machines in a network. In Selenium Grid, there is only one hub, which allocates test execution to a particular node based on capability matches.
Node is a test machine where test cases actually run.
Selenium-Node-Container
For more details on Selenium Grid, follow the tutorial here.
The typical process to set up Selenium Grid has caused testers sometimes to face difficulty in connecting the node to the hub.
In Selenium 4, the Grid experience is going to be easy and smooth. There will not be any need to set up and start the hub and node separately. Once we start Selenium Server, the Grid will act as both hub and node.
Selenium 4 will come up with a more stable Selenium Grid in terms of removing all thread-safety bugs, and better support for Docker.

Better Selenium Grid UI

Selenium 4 will come with a more user-friendly UI for Grid, with relevant information about sessions running, capacity, etc.

Better Observability

“Passive observability is the ability to do descriptive tracing.”  – Simon Stewart
Observability, logging, and debugging are no longer confined to DevOps in recent times. As part of this release, request tracing and logging with hooks will be improved so as to provide automation engineers a hold on debugging.

Refreshed Documentation

Documentation plays a key role in any project’s success. The Selenium docs had not been updated since the Selenium 2.0 release. In the latest upgrade, Selenium's documentation is also going to be refreshed and detailed. You can access it here.
Here’s a video from Selenium Conference 2018, held at Bangalore recently:

Selenium 4 in a Nutshell

Upgrading to the latest version of Selenium should not require any code changes. Setting up nodes and hubs will become smooth and the entire grid experience is going to be streamlined. For automation engineers, the latest version should not be challenging and existing automation frameworks should work with minimal changes.

Wednesday, 18 July 2018

Install Sauce Connect on Mac OSX and Run from local

   Install Sauce Connect on Mac OSX



Install the App

  1. Press Command+Space and type Terminal and press enter/return key.
  2. Run in Terminal app:
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null ; brew install caskroom/cask/brew-cask 2> /dev/null
    and press enter/return key. 
    If the screen prompts you to enter a password, please enter your Mac's user password to continue. When you type the password, it won't be displayed on screen, but the system would accept it. So just type your password and press ENTER/RETURN key. Then wait for the command to finish.
  3. Run:
    brew cask install sauce-connect
  4. In terminal set all the required parameter
  5. export SAUCELABS_HOST="127.0.0.1"
    export SAUCELABS_PORT="4448"
    export SAUCELABS_USER_NAME="<YOUR USER ACCOUNT>"
    export SAUCELABS_KEY="<YOUR SAUCELABS LAB KEY>"
    export SAUCE_LAB_GULP_TASK="<TASK NAME>"
    export SAUCELABS_TUNNEL="Tunnel Name"
    export APPLICATION_ENVIRONMENT="ENVIRONMENT NAME"
  6. Execute below command once the parameter set in terminal
  7. sc --no-autodetect -u $SAUCELABS_USER_NAME -k $SAUCELABS_KEY -i $SAUCELABS_TUNNEL -l /tmp/sauce_connect.log --se-port 4448

Sunday, 5 February 2017

EXTRACT CSS PROPERTY VLAUE OF PSEUDO ELEMENTS CONTAINING :after/:before CSS TAG USING JAVASCRIPT IN WEBDRIVER :

We cannot extract css properties of pseudo elements using web driver commands such as ‘.getPropertyValue’ . For this, we need to use JavaScript and execute a js script in selenium web driver.


A CSS pseudo-element is used to style specified parts of an element.
   For example, it can be used to:
   Style the first letter, or line, of an element
   Insert content before, or after, the content of an element

ISSUE:



In above scenario, we need to get the text “Internal Use Only” from UI which is associated with an Anchor (a) tag in DOM with :after CSS tag. The text is present in “content” Style Property as shown in right highlighted box.

The :after CSS tag cannot be located directly using web driver and thus required text cannot be retrieved simply by using .getPropertyValue() function in selenium.

To achieve this, a javascript needs to be executed in our selenium code :

WebElement elementObj = driver.findElement(By.xpath("<YourXpath>"));
String pseudoElementText = ((JavascriptExecutor)driver).executeScript("return window.getComputedStyle(arguments[0],':after').getPropertyValue(content');", elementObj).toString();

System.out.println(pseudoElementText);


In same way we can extract another properties values as well.

Thanks


Translate







Tweet