Button is not getting clicked using Robot framework with playwright library

Viewed 320

I am using Robot Framework with Playwright library. I am having some issue when clicking on Save/Spara button inside a tbody. Other button is getting clicked just fine but having issue only with this one.

When i use css and text selectors i am getting a console error message after timeout “TimeoutError: locator.click: Timeout 10000ms exceeded.” And when i use absolute xpath i get console error message “Unexpected token “/” while parsing selector”. I also realised that the focus from a previous element was not moving onto this button so i specifically introduced Tab key in my script and now the focus is on Button but its still not getting clicked.

I have tried following locator:

Click xpath=//button[@class="btn btn-success"]

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’)]

Press Keys xpath=//button[@class="btn btn-success"] Enter
When i used Press Keys, before this i had already moved the focus onto this button. But i got same console error.

Here is the element i am trying to click:

<button title="Spara" class="btn btn-success" data-bind="click: $root.SparaAllaVaccinationer, visible: $root.SparaVaccinationEnabled($data)" style="">
                            <i class="fa fa-2x fa-save"></i><br><span class="small">Spara</span>
                        </button>

Has anyone faced similar issue ?

1 Answers

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

Related