Check Xpath for attribute

I need to check if web-element has an attribute or not. In my case it’s a button, which I have to check if it has an attribute Disabled=""

If button-element is enabled, it does not have this attributes and I cannot utilize “Use element attributes” as my recording crashes to an error:

Error executing WebElementAction Error executing TemplateAction[templateName=WebElementAction.ftl,id=34,name=Optional[WebElementAction],parent=21,nextSibling=35,arguments=ActionArguments[varName=[tmp_string],elementAttribute=[disabled],exactMatch=[true],xsi:type=[recorder:WebElementAction, recorder:WebElementAction],pollingInterval=[300],active=[true],searchInFrames=[false],delay=[1000],useElementAttribute=[true],webElementLocatorType=[XPATH],actionDetails=[(get by //[@id=“butValidNewCustomer”] xpath)],webElementLocator=[//[@id=“butValidNewCustomer”]],awaitTimeout=[5000]]]


Hi @janne_mustonen

try putting the Get value action in Exception Handling, so the script doesn’t fail even if the attribute doesn’t exist, and put the actions the bot has to perform if the attribute doesn’t exist in the “If an exception occurred” block.

“Exeptional” solution to the problem :grin:

Works perfectly, thank you for the solution! :+1:

1 Like

Glad I could help! :grinning: