"The selector is not valid"

Hi Uipathians,

I am getting below exception when am using the expression:

“<webctrl aaname=”+User1+” parentid=‘searchResult’ tag=‘DIV’ />"

User1 being the variable that I have defined for a username

Any help on this is highly appreciated!
Thanks!
18.3.1+Branch.master.Sha.4c05f670b311e90ee097c589605b399e9bee4874

Source: Click ‘DIV’

Message: The selector is not valid

Exception Type: UiPath.Core.InvalidSelectorException

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
UiPath.Core.InvalidSelectorException: The selector is not valid ----> System.Xml.XmlException: ‘Gaguzef’ is an unexpected token. The expected token is ‘"’ or ‘’'. Line 1, position 66.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String args)
at System.Xml.XmlTextReaderImpl.ThrowUnexpectedToken(String expectedToken1, String expectedToken2)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.LoadXml(String xml)
at UiPath.Core.Selector.FromXmlString(String xml)
at UiPath.Core.Selector…ctor(String theSelector)
— End of inner ExceptionDetail stack trace —
at UiPath.Core.Activities.ScopeActivity.OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Try this one
"<webctrl aaname='"+User1.ToString()+"' parentid='searchResult' tag='DIV' />"

Regards,
Arivu

1 Like

you can debug to check the value of selector is what you wanted

you missed ‘’ (single quotes for the aanmae attribute. Its required that is why when user is Gaguzef its unable to identify it.)
Use the selector provided by Arivu

Thanks @arivu96!
Single quotes and converting to string helped me out.

PS: I read in various posts that single quotes are not to be used that’s why did not.

One query: My variable is already of type String, then why do we require to explicitly convert it into String, like again?

then no need to do the conversion :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.