Reading the documentation I found that using the function click()
of page
element is discouraged, as we can see here.
Instead, we can use the locator.click()
method, as shown here.
I am interested in understanding if there’s some technical difference between the two methods, and if so what’s exactly this difference.
I am recently updating a bunch of old functions created a year ago or so, and for some reasons when I change for example
await this.page.click('.add-card')
with
await this.page.locator('.add-card').click()
the behaviour changes, and some elements are not waited anymore; so the test fails.
I am pretty sure I need to change the rest of the code before trying to run everything again, since I think the issue is due not to this change but to the various old functions present.
But nonetheless I am interested to better understand if there’s something that changes in the click
function, or if nothing really changes.