Split text with line break is not working

I have taken values from xpath which is a list but when saved it in one variable it is saves like a string and list contain only one element. When I tried to split the string with windows line break it was not working.Capture

How to take those option values in list?

HI @abhimanyu_thit please share your recording to have a look at the action details.

Here are images of the code.

@abhimanyu_thit try using Linux line break, or using an Xpath that works for all options and save to a list variable. Try using this xpath //*[@id=“allCategories”]//option. Does it work in this case?

Error executing WebElementAction
com.workfusion.studio.rpa.recorder.playback.PlaybackException: Error executing TemplateAction[templateName=WebElementAction.ftl,id=5,name=Optional[WebElementAction],parent=2,arguments=ActionArguments[varName=[persons],elementAttribute=[option],exactMatch=[true],xsi:type=[recorder:WebElementAction, recorder:WebElementAction],pollingInterval=[300],active=[true],searchInFrames=[false],delay=[0],useElementAttribute=[false],webElementLocatorType=[XPATH],actionDetails=[(get by //[@id=“allCategories”]//option xpath)],webElementLocator=[//[@id=“allCategories”]//option],awaitTimeout=[5000]]]
at com.workfusion.studio.rpa.recorder.playback.flow.StandardControlFlow.execute(StandardControlFlow.java:54)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.execute(TemplateAction.java:28)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.execute(TemplateAction.java:15)
at com.workfusion.studio.rpa.recorder.playback.player.ActionPlayer.next(ActionPlayer.java:64)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.playNextAction(PlaybackLogic.java:152)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.run(PlaybackLogic.java:112)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression //[@id=“allCategories”]//option because of the following error:
SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string '//
[@id=“allCategories”]//option’ is not a valid XPath expression.

@abhimanyu_thit looks like there is a wildcard (*) missing in the Xpath.

Can you share the url of the page?

@ashapkina Not able to share the URL due to it is not accessible outside the our network.
this is xpath of that component.
//*[@id=“allCategories”]

Does the xpath //*[@id=“allCategories”]//option point to all values you need to save like in the example below?

How did I find whether it is pointing to all options or not?

I am using //*[@id=“quickAddCandidateForm”]/table[2]/tbody/tr[1]/td[2]/table/tbody/tr/td[1] this XPath, and it will gives all value in one string with separated by new line if I print in notepad.

If I used List variable then list having only one variable of this big string. and normal string variable not able to split it with windows line break. I tried with linux line break as well.

@abhimanyu_thit try this solution

let me know if it doesn’t work

If it doesn’t work, you can see how to use Xpath to save values to a list in this video https://youtu.be/h2kqMrGv5kk?t=430

Thank you so much @ashapkina it is working. :slight_smile:

1 Like