Button is not getting clicked

I am using Robot Framework with Playwright library and using Python language. There is an issue when trying to click on a button. All other buttons are getting clicked just fine except one. Its always getting timeout when i use the css or text selectors with console message “TimeoutError: locator.click: Timeout 10000ms exceeded.”
And when i use xpath i am i getting console message “Unexpected token “/” while parsing selector”. I have also tried introducing sleep statements but it didn’t work.

Here is element i am trying to click:


Spara

Does anyone know what could be the issue ?

DOM Element I am trying to click:

Can you share your locators ?

I tried following locators:

Click button[data-bind=“click: $root.SparaAllaVaccinationer, visible: $root.SparaVaccinationEnabled($data)”] i[class=‘fa fa-2x fa-save’]

Click button[title=“Spara”]

Click //button[contains(@title,‘Spara’)]

I also tried following:

Press the tab key to move focus from drop-down

Press Keys [aria-owns=“platsLokationDropdownlist_listbox”] Tab

Focus moved onto button which script needs to click.

Focus //button[contains(@title,‘Spara’)]

Sleep 15s

Press Keys //button[contains(@title,‘Spara’)] Enter

I can see clearly that focus is on the button but its not getting clicked.

But still no success. Same Error message in console : TimeoutError: locator.press: Timeout 10000ms exceeded.
=========================== logs ===========================
waiting for selector “//button[contains(@title,‘Spara’)]”

I got it resolved by using:

Press Keys xpath=//button[@class=“btn btn-success” and contains(text(),‘Spara’)] Enter

But i would really appreciate if someone can explain why it was not working with simple Click action with class in xpath
Click xpath=//button[@class=“btn btn-success”]
OR
Press Keys xpath=//button[@class=“btn btn-success”] Enter

Thanks for the information i have same issue but still not get answer can anyone explain me i details.

I would suggest execute your script with headless=false and add sleep time of approx 15 seconds before the click of button. Now when the script waits have a look on UI what happens. There could be few things you can try:

  1. Press Keys LocatorXpath=//whateverOfPreviousElementThanButton Tab

// Tab will move the focus from previous element onto next element which i am assuming is your Click button.

  1. Press Keys LocatorXpath=//ForButtonToClick Enter
    // Enter will press the keyboard enter and locator should be of you button you want to click.

NOTE: When you perform the Step1 ensure that tab is moving the focus to correct element which you want to click.
I hope it’ll help.