codeceptjs / CodeceptJS

Supercharged End 2 End Testing Framework for NodeJS

Home Page:http://codecept.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Playwright to codecept locator conversion

dylanahoang opened this issue · comments

What are you trying to achieve?

I want to create a Playwright locator by using features not supported by Codecept+Playwright
(a) react component selection ("_react=XXX")
(b) data-testid selection against the virtual/shadow DOM ("[data-testid='testdonebutton']")

I then want to use Codecept assertions against these Playwright locators
I.see(pwLocator.toString())

What do you get instead?

I get a variety of issues including XPath conversion failing and certain selector string fragments not being recognized like "_react"

Details

I can't not use Codecept assertions because my code base is cross platform and we'll eventually want to support react-native based assertions. Figuring this out will help us really speed up our test development Do you have any recommendations?

@dylanahoang good idea

I think you can extend Locator class to support { type: 'playwright' } and I think this would be the way to natively pass PW locators as you describe.

You can make a PR with that!

Sounds good, thanks for the quick response!

https://codecept.io/react/#locators

I think codeceptjs already provides this _react but with codeceptjs syntax. Does it work for you @dylanahoang ?

With Playwright, React locators work via Playwright React Locator (opens new window).