UFT One WebElement element recognition and regular expression evaluation

Hi there!

I'm hoping someone will have encountered a similar issue, as I've really been having trouble with getting a certain element on a page to be recognized using WebElements in UFT One (CE 24.2). For a bit of context, I am attempting to verify certain parameters for documents uploaded to OpenText Content Server.

The two elements in question are:

1. <a href="/otcs/(...)" target="info">r-[XXXX]-YYYYYYY-(Workspace-Coordinators)</a>
2. <a href="/otcs/(...)" target="info">r-[XXXX]-ZZZZZZZ-AA-DIR-(Director's-Office)</a>

To recognize the elements, I have attempted to use the following:

If Browser("Main").WebElement("html tag:=A", "innertext:=r\-\[XXXX\]\-YYYYYYY\-AA\-DIR\-\(Director\'s\-Office\)").Exist Then

If Browser("Main").WebElement("html tag:=A", "innertext:=r-[XXXX]-YYYYYYY-AA-DIR-(Director's-Office)").Exist Then

I noticed that UFT was able to recognize the link on the page with r-[XXXX]-ZZZZZZZ-AA-DIR-(Director's-Office) when escaped, but not r-[XXXX]-YYYYYYY-(Workspace-Coordinators) while in its original form and escaped. The regular expression evaluator confirms that the escaped version of the inner text should match in theory, for both elements.

Are there any limitations that I should be aware of that I'm missing? The other question is whether there is a way to disable regular expression parsing in the WebElement innertext search (i.e., taking a string as literal), which would help me reduce the number of things going on (I am currently using some code to escape the text).

As an aside, I am not sure that I can use object spy/identification as the text for these elements come in from an external spreadsheet, but if this is possible, I'm all ears.

Thanks,

Andrew

  • Verified Answer

    +1  

    Descriptive programming by default treats the values as regular expressions.

    To disable it, you will need to use a different way to script, check the example from below page for details:

    Properties Object (Collection) (microfocus.com)

    I did not get your last question though, but basically whatever descriptive programming can achieve should be achievable with OR as well.

  • Verified Answer

    +1 in reply to   

    Thank you for the reply! I tried the Description method:

    Set TestDesc = Description.Create()
    TestDesc("text").Value = "r-[XXXX]-YYYYYYY-(Workspace-Coordinators)"
    TestDesc("text").RegularExpression = false
    TestDesc("html tag").Value = "A"
    
    If Browser("Main").Page("Flow").Link(TestDesc).Exist(3) Then
        MsgBox("Element found")
    Else
        MsgBox("Element not found")
    End If

    I grabbed the text directly from the Object Spy/Object Repository, but it seems that UFT is still unable to identify this element in particular. On the bright side, you've helped me rule out regular expressions as the issue, which I had suspected as a possibility.

    Eventually, I was able to coax it to work, and there are two main things I changed:

    - I manually identified the container enclosing the element

    - I used the HTML id of an element under the container which was guaranteed to be the parent of any link that I needed to search for.

    I am not fully certain on exactly which change resolved the issue, but in retrospect, it was probably because there were two elements with similar properties and with the lack of specificity, there was a conflict.