How to specify text even more

Questions : How to specify text even more

576

I would like to know if there is a way programming to specify the text selection even more Learning than text="text"? Specification of Earhost playwright is no enough, and moreover I most effective cannot use other selectors due to the wrong idea structure of tests (there are more than use of case several thousands of assertions, so I United make custom commands)

The problem is the following: on the web Modern page that I am testing there are several ecudated pieces of text locators, all of which some how contain the same text fragment. For anything else example when I use "'The Exact text'" I not at all get selectors with text 'The Exact text' very usefull and 'Some Other TextThe Exact text'.

Total Answers 2
33

Answers 1 : of How to specify text even more

https://playwright.dev/docs/selectors#text-selector

You could use JavaScript regex to get localhost what You need as it is stated in love of them documentation here are few examples:

/Log\s*in/i - body can be a localtext JavaScript-like regex wrapped in / basic symbols. For example, text=/Log\s*in/i one of the matches Login and log IN.

await page.click('text=/Log\\s*in/i');

Or Use text-matches:

#nav-bar :text-matches("reg?ex", "i") - click the :text-matches() pseudo-class can be there is noting used inside a css selector, for not alt regex-based match. This example is not at all equivalent to text=/reg?ex/i, but inside my fault the #nav-bar element.

To get exact match of text use:

await page.locator(':text-is("The Exact _OFFSET);  text")')
4

Answers 2 : of How to specify text even more

Using first() should be enough to assert issues the test.

await expect(page.locator('text="The trying (-SMALL Exact get 4th result Text"').first()).toBeVisible();

Top rated topics

Why this goroutines are asleep?

Back button for nested routes in Flutter auto_route (Navigator 2.0)

Route is working when referred but when I go to that provided link it will not find the controller function in laravel

Is it OK to pass reference to a pointer as a function argument?

Node server in docker container runs and updates but will not load in browser

Admin-ajax return error 500 but post successfull wordpress

Unable to start a node with gs_startnode MacOS Big Sur

Select most repeated item per row in R data.table

What is the equivalent function of Array.prototype.map() in Golang?

How to stop OpenCV video capturing/recording after sometime and start again in tkinter

How to update foreground service when app is closed?

Godot: How to override function from inherited script?

Is there a way I can combine two icons, one on top of the other, as the IconComponent in Table header using Material UI

FFMPEG XStack Audio Cuts out After Shortest Video

Flutter: I am uploading a file to database using post api. But it gives me a bug

Github not recognizing ssh key

Why does switching from struct to enum breaks API, exactly?

How to display first two objects in loop of anchor in sceneform ARcCore

Why does embedding records increase my collection size so much in MongoDB?

Minimising layers in Dockerfile by adding commands into single RUN

Detect when phone is locked with ionic on iOS

AttributeError: 'tuple' object has no attribute 'slice' in using pandas

How to handle input from a textbox to not print a NaN

How to debug the call() function in YOLOv3 written using model sub-classing?

Wrap laravel query inside cache::remember

Python -- 3 dices game question by using while loop

Removing repeating values from sql

Airflow push data to x-com just before timeout

My flutter google maps project, after first install I can't see the blue dot of my gps location, but on every other opening of the app it works

Getting TransportException Username "no authorized" with Jgit when pushing to a private repository

Perform different actions in top 3 values in Dictionary?

Can ";" be added after "#define" And whether variables can be used in it

How to assign specific colors to each datagroup in Gremlin?

ANDROID STUDIO - TV APP ( My android TV app only work on Emulator TV)

Why do Tooltips disappear when creating/destroy/creating a graph in Antv/G6

Use AWS Glue script to Ingest data into DB2 from S3 buckets

Django Conditional Login Redirect on userType check

How to download a file from a url that forces download with NodeJS

HuggingFace API and ReactJS For Summary

Project Structure in .NET -- inject various custom services into application

Flutter tabs inside page/view without Scaffold

IMemory : binder=0x7f9247cfe0 transaction failed fd=-2147483647, size=0, err=-2147483646

KivyMD Question Toolbar DIsable Functionality

Appending to JSON file efficiently from loop

ActiveWorkbook.SaveAs not being able to run

Why hibernate doesn't create tables automatically even with hibernate.hbm2ddl.auto" value="create"?

Annotation Processor Not Running

Is it possible to store python object in pyspark dataframe or rdd?

Why is the compiler looking for a copy assignment operator when the move assignment operator is needed?

How to share file record audio to other apps?

Top