I have a problem with playwright using python for automation, when I manipulate a button on the website, i had a problem, because it gives me an error, first I will show the code in Python
button = page.locator("button.p-ripple").first()
button.click()
In this case, I want to press this button, it is inside a p-button, apparently an element used in Angular.
This is the result when selecting the element from the DOM
document.querySelectorAll("button.p-ripple")
result -> NodeList [ button.p-button.p-component.p-ripple ]
This is the result right after placing the indexing, it finds the element
document.querySelectorAll("button.p-ripple")[0]
result -> <button class="p-button p-component p-ripple" pripple="" type="button">
I wanted to do the same with playwright using python, but neither first() nor nth(index) work for me, this error appears
‘Locator’ object is not callable
File “/file.py”, line 84, in function_python
button = page.locator(“button.p-ripple”).first()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/file.py”, line 133, in main
function_python(page)
File “/file.py”, line 140, in
main()
TypeError: ‘Locator’ object is not callable
(on line 84 is where the locator is, on line 133 is where the function I created within the main function is located, its function is to call the browser page, on line 140 is the main function that I call in the initializer)