Getting error Invalid character at character position for select dropdown with innertext

Ask general questions here.
praneet
Posts: 17
Joined: Thu Nov 08, 2018 2:22 am

Getting error Invalid character at character position for select dropdown with innertext

Post by praneet » Wed Dec 12, 2018 3:06 pm

Hi Team,

We are using Ranorax latest licensed version 8.3.0.
We are getting issue while selecting dropdown incase of special character ' in innerText.

Error Message:-
Invalid RxPath './/option[@innertext='Renorex's Forum']'.
Invalid character at character position 71.

In the above example my innerText value is dynamic that can be pass from external file.
Most of the cases it's working cool(Data doen't have any special characters) but in some cases it's failing may be because of special characters in innerText i.e Renorex's Forum.

So could you help me out.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4802
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Getting error Invalid character at character position for select dropdown with innertext

Post by odklizec » Thu Dec 13, 2018 11:01 am

Hi,

At first, there is a new Ranorex version 8.3.1, with a lot of bugfixes. Please install this version and try to repeat your problem.

At next, could you please show us how exactly do you select dropdown items in your recording/code module? I'm not aware of any problem caused by apostrophe character? So if the apostrophe is indeed a cause of your problem, you will have to check and modify the ref data. Eventually, use regex expression in the xpath (~) instead of simple equality and remove problematic characters from the ref data.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

ahoisl
Certified Professional
Certified Professional
Posts: 175
Joined: Fri Sep 07, 2007 8:16 am

Re: Getting error Invalid character at character position for select dropdown with innertext

Post by ahoisl » Fri Dec 14, 2018 3:19 pm

The error signals a syntax problem with your RanoreXPath.
If you have a tick ' in a value in RanoreXPath, you have to escape the tick by preceding it with another tick, e.g.:
element[name='Alex'' element'] will match an element with name set to "Alex' element".

Regards,
Alex
Ranorex Team

praneet
Posts: 17
Joined: Thu Nov 08, 2018 2:22 am

Re: Getting error Invalid character at character position for select dropdown with innertext

Post by praneet » Mon Dec 17, 2018 8:57 am

Tried with RegEx then problem solved.
Below is the code used to select dropdown which has text with specialchar

OptionTag option = item.FindSingle(".//option[@innertext~'^textName']");
option.Selected = true;