Skip to content Skip to sidebar Skip to footer

Coded Ui - C# - Executescript - Count Does Not Return Value Correctly

I am observing a strange behavior using ExecuteScript in Coded UI. When two numbers are next to each other, count does not return the correct value. I'm not sure why it's happening

Solution 1:

The problem with your current approach is that you search the entire markup source for four-digit numeric strings, which are likely to occur somewhere.

I suggest three improvements:

  1. Search in innerText, not in innerHTML. In this way numbers that are part of invisible tags like scripts, are excluded
  2. Target the tag(s) that contain the year numbers specifically. Inspect the markup to find the appropriate criteria for a selector, for example an id value:

    document.getElementByID('yearspan').innerText

  3. search for whole words only, not with the indexOf function. Find an example of how that can be done here: https://stackoverflow.com/a/2232947/1132334

Post a Comment for "Coded Ui - C# - Executescript - Count Does Not Return Value Correctly"