Comments (4)
You can click on that element (purple circle on screenshot) using Xpath //div[@class='p-datatable-wrapper']/table/tbody/tr[1]/td[10]/a[@class="edit css-1hqfesk"]
You can join Playwright Slack channel if you like playwright.slack.com.
from demo.playwright.
@lmlikota XPath can be fragile, and the css class will likely be dynamic and change in this case, so it should be avoided as selector.
@ramnutheti Are you looking to validate the table data? For that, you would query the page with specific selectors for the table, then assert its contents.
e.g.
await expect(page.locator('.my-table-row').nth(3)).toContainText('Job');
You can also use locators to work with element lists: https://playwright.dev/docs/locators#lists
from demo.playwright.
@MarcusFelling Are you suggesting not to use Xpath and CSS selectors? But in your above example you have used .mytable row
which is CSS class, nth(3)
which is index and toContainText
which is also something that CSS doesn't support out of the box but Xpath does .
So above example is combination of CSS selector using Class, index and partial text is not tied to DOM changes? How come if it relies on CSS class, row index and partial text? If any of them change in DOM this locator will fail. I'm trying to understand how is this better then writing relative Xpath.
So in Xpath your above example would be:
await expect(page.locator('//*[@class='my-table-row'])[3]/*[contains(.,"Job")]')
from demo.playwright.
https://playwright.dev/docs/selectors#best-practices
from demo.playwright.
Related Issues (11)
- Oauth example improvements
- [Idea for testing scenario] websockets HOT 1
- [Idea for testing scenario] drag & drop HOT 1
- [Idea for testing scenario] four-layer testing architecture HOT 1
- [Idea for testing scenario] fixures
- [Idea for testing scenario] Chrome Extension
- [Idea for testing scenario] Using fixtures with multiple browser windows/tabs in single test HOT 1
- [Idea for testing scenario] Cucumber HOT 1
- Make local run easier HOT 1
- Page Object model patten HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from demo.playwright.