Hi everyone,
I want to ask you about a bug that is stumping me.
My environment was originally built using full XPaths for the locators. To increase the stability of the system I am changing those locators to relative XPath locators using specific test automation tags for each element. The automation tags are added to the elements manually by my developers, because they work in OutSystems.
This has been working great up to this moment. But now one of the new, relative XPath locators is breaking my code. This happens only in one specific location and not in others. It is the locator for a slider element.
Old locator
xpath=/html/body/form/div[4]/div/div/main/div/div/div[2]/div/div[1]/div/div[2]/div/fieldset/div/div/div/div[2]/div/div[2]/div
New locator
xpath=//div[@data-automation=‘Foo_Bar’]
This is what I mean by ‘slider element’
For other locators (text fields, dropdown menu’s, checkboxes, messages, buttons) I have been able to use the new XPaths succesfully. Before, I was able to run my code to find the slider using the old XPath. And both the old and the new XPath point to the exact same element, the exact same div.
I am using this locator in two different places: in a custom made keyword and in a separate test scenario. When I run the test scenario the locator works fine, but in the keyword it results in a time out error.
Error message
‘TimeoutError: locator.hover: Timeout 10000ms exceeded.’
When I change the ‘hover’ action to something else (click for instance) the problem persists.
This means the locator itself is not broken, otherwise how could it be functional in the separate test scenario? However, the keyword can not be broken either, because it works fine when I use the old, full XPath locator.
Why do these two things that work well independently, the locator and the custom keyword, break down when I combine them?!? I am stumped.
Please let me know if you need additional information, and thanks for your time and support.
RobotFramework version: 5.0.1
IDE: Visual Studio Code
OS: Windows 10 Business
Browser: Chrome
Hover action comes from the Browser Library (based on Playwright)