webdriverio / codemod

A codemod to transform Protractor into WebdriverIO tests
MIT License
25 stars 12 forks source link

Chained protractor selectors aren't transformed correctly #29

Closed alebx closed 2 years ago

alebx commented 3 years ago

When transforming this chained selector:

await table.element(by.className('datatable-header')).all(by.className('datatable-header-cell-label'))).click();

It turns into this:

await table.$(".datatable-header").$$(".datatable-header-cell-label").click();

Which isn't a valid async selector.

christian-bromann commented 3 years ago

@alebx thanks for reporting!

Can you explain what happens here:

await table.element(by.className('datatable-header')).all(by.className('datatable-header-cell-label'))).click();

is it clicking on all elements it finds?

alebx commented 3 years ago

@christian-bromann thanks for the quick reply! Yes, that's exactly what's happening. I know I could rewrite the selector, but that would mean a major rewrite of our code base.

christian-bromann commented 3 years ago

So WebdriverIO with the latest version allows you to click on specific elements, e.g.:

await table.$(".datatable-header").$$(".datatable-header-cell-label")[0].click();

but it won't click on all elements. You would need to iterate over them, e.g.:

await for (const elem of table.$(".datatable-header").$$(".datatable-header-cell-label")) {
    await elem.click()
}
christian-bromann commented 2 years ago

I think this issue is resolved. Closing.