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

Ask general questions here.
praneet
Posts: 38
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: 7470
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: 192
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: 38
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;

alkeer
Posts: 2
Joined: Fri Dec 11, 2020 2:26 pm

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

Post by alkeer » Tue Jul 12, 2022 1:10 pm

If you are using excel as a datasource in some part of your Ranorex project. It is higly likely that you will get an "Invalid character at character position XXX" error. The reason behing is in older excel version or office runtime distributable binaries like "Microsoft Access Database Engine 2016" the excel cell values after 256th character is truncated. The runtime reads only the first 256 characters of each cell of excel file.

The workaround is simple. You just need a dummy excel cell IN YOUR FIRST DATAROW (i.e. the 2nd excel row) with a celldata that has more than 256 characters inside it.

Here is another forum post about the same issue: https://www.mrexcel.com/board/threads/c ... ed.972147/

Here is the actual description of problem from microsoft: https://docs.microsoft.com/en-us/office ... -truncated