2

Need to set a property of an object at runtime. However the property values require certain regular expression. For example -

Browser("IE").Page("newpage").WebElement("First").Settoproperty "innertext", "over.*"

It seems this is not possible except setting it through OR. Any ideas ?

Pranav
  • 437
  • 3
  • 19
  • 1
    You can mark the property to use regular expression in your OR itself and then if you do SetTOProperty and use a regex it should workas expected. You cannot change the regex flag of that property through SetTOProperty. Mark the Property to use regular expression and if you don't want to use regex for the property escape the wildcard characters with a backslash and it will not be considered as regex. – user5612655 Mar 02 '20 at 09:32

1 Answers1

1

You are correct, SetTOProperty does not change whether a property is treated as a regular expression. This means that if the property in the Object Repository is using the default "not-regex" setting, then SetTOProperty will not be able to utilise regular expressions1.

If you want to use regular expressions you should use Descriptive Programming which uses regular expressions by default (although they can be turned off).


[1] Thanks to TheBlastOne for the comment correcting my inaccuracy.

Motti
  • 110,860
  • 49
  • 189
  • 262
  • Isn't it so that SetTOProperty does not support *changing* the regular expression setting as set in the OR? If it is not marked, SetTOProperty sets the value, and one must specify a literal. If it is marked as refexp, SetTOProperty sets the value, and one must specify a regexp. So SetTOProperty does support regexps if the OR item is configured for that. Right? – TheBlastOne Aug 18 '22 at 09:35
  • Hi @TheBlastOne, long time no see! :) I'm sorry I don't remember the details for this. It makes sense that if the description in the OR is set to use regex then setting the value will maintain that flag but I'm not sure if that's the case, it should be easy to check. – Motti Aug 21 '22 at 06:24
  • 1
    Did that. It uses the RegularExpression value as is, so it cannot be changed programmatically at runtime. I.e. the statement "SetTOProperty does not support regular expressions" is false, since it indeed does, but only if the OR element is configured accordingly to be a regexp, and that config cannot be changed during runtime. – TheBlastOne Aug 29 '22 at 18:02