Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WebElement not found in OR
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
I have a WebElement that is not being found in the OR.

On the webpage, the page webelement in Spy indicates the innertext = **Account 12345678 is invalid or you are not authorized to view this account.**

I use:
Code:
If  Browser("Wisdom").Page("Wisdom IA").WebElement("**Account1").Exist(0) Then
In the properties, innertext is set a a regular expression (Repository Parameter) constant is "**Account " & ACCT1 & " is invalid or you are not authorized to view this account.**"
ACCT1 is a passed in variable 12345678

What must I do differently to find this value in my OR.

Or do I use:
If Browser("Wisdom").Page("Wisdom IA").WebElement("innertext:=" & "**Account " & ACCT1 & " is invalid or you are not authorized to view this account.**").Exist(0) Then
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Sometimes it is difficult to verify webelements text if their properties change dynamically, in these situations the other way round is to verify whether the expected message is displayed on the page or not.

Code:
Set oPage = Browser().Page()
Set oDescWebElement = Description.Create
oDescWebEement("micclass").value = "WebElement"
oDescWebElement("visible").value = True
bFndFlag = False
Set colWebElements = oPage.ChildObjects(oDescWebElement)
For iCnt=0 to colWebElements.Count-1 Step 1
      If colWebElements(iCnt).GetROProperty("outertext") = "Expected Text" Then     ' use Instr if specific text needs to be checked
           bFndFlag = True
           Exit For
      End If
Next
If bFndFlag = True Then
     Print "passed: text found on the page"
Else
     Print "failed: text not found on the page"
End If

An alternative way would be to capture the text as displayed in Page source using msxml object. For details on msxml object refer book ' Test automation and qtp - excel with ease'
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Sometimes it is difficult to verify webelements text if their properties change dynamically, in these situations the other way round is to verify whether the expected message is displayed on the page or not.

Code:
Set oPage = Browser().Page()
Set oDescWebElement = Description.Create
oDescWebEement("micclass").value = "WebElement"
oDescWebElement("visible").value = True
bFndFlag = False
Set colWebElements = oPage.ChildObjects(oDescWebElement)
For iCnt=0 to colWebElements.Count-1 Step 1
      If colWebElements(iCnt).GetROProperty("outertext") = "Expected Text" Then     ' use Instr if specific text needs to be checked
           bFndFlag = True
           Exit For
      End If
Next
If bFndFlag = True Then
     Print "passed: text found on the page"
Else
     Print "failed: text not found on the page"
End If

An alternative way would be to capture the text as displayed in Page source using msxml object. For details on msxml object refer book ' Test automation and qtp - excel with ease'

Sometimes it is difficult to verify webelements text if their properties change dynamically, in these situations the other way round is to verify whether the expected message is displayed on the page or not.

Code:
Set oPage = Browser().Page()
Set oDescWebElement = Description.Create
oDescWebEement("micclass").value = "WebElement"
oDescWebElement("visible").value = True
bFndFlag = False
Set colWebElements = oPage.ChildObjects(oDescWebElement)
For iCnt=0 to colWebElements.Count-1 Step 1
If colWebElements(iCnt).GetROProperty("outertext") = "Expected Text" Then ' use Instr if specific text needs to be checked
bFndFlag = True
Exit For
End If
Next
If bFndFlag = True Then
Print "passed: text found on the page"
Else
Print "failed: text not found on the page"
End If

An alternative way would be to capture the text as displayed in Page source using msxml object. For details on msxml object refer book ' Test automation and qtp - excel with ease'
Sometimes it is difficult to verify webelements text if their properties change dynamically, in these situations the other way round is to verify whether the expected message is displayed on the page or not.

Set oPage = Browser().Page()
Code:
Set oDescWebElement = Description.Create
oDescWebEement("micclass").value = "WebElement"
oDescWebElement("visible").value = True
bFndFlag = False
Set colWebElements = oPage.ChildObjects(oDescWebElement)
For iCnt=0 to colWebElements.Count-1 Step 1
If colWebElements(iCnt).GetROProperty("outertext") = "Expected Text" Then ' use Instr if specific text needs to be checked
bFndFlag = True
Exit For
End If
Next
If bFndFlag = True Then
Print "passed: text found on the page"
Else
Print "failed: text not found on the page"
End If

An alternative way would be to capture the text as displayed in Page source using msxml object. For details on msxml object refer book ' Test automation and qtp - excel with ease'
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
Thx Rajeevszone,

When I do an OSpy, I find
Browser("Wisdom").Page("WisdomMain").WebElement("**Account 12345678 is invalid or you are not authorized to view this account.**")

The 12345678 changes depending on which account was entered. From the OR Manager the element does highlight when I I do a View-> Highlight in App.

If I go back and try the same exact code that just found the WebElement that earlier worked; now using
Browser("Wisdom").Page("WisdomMain").WebElement("Account 12345678 is").Highlight, the WebElement is not found in the OR.

I then tried:
ACCT1 = 12345678
WebElement("innertext:=" & "**Account " & ACCT1 & " is invalid or you are not authorized to view this account.**") but this code did not work.

I then went into the OR and changed the innertext to read "**Account " & ACCT1 & " is invalid or you are not authorized to view this account.** and selected a RegEx, no luck in finding the webelement.

Then I tried yours replacing Expected Text = Expected Text with "**Account " & ACCT1 & " is invalid or you are not authorized to view this account.**"

t o read:
If colWebElements(iCnt).GetROProperty("innertext") = "**Account " & ACCT1 & " is invalid or you are not authorized to view this account.**" Then
and
If colWebElements(iCnt).GetROProperty("innertext") = "**Account 12345678 is invalid or you are not authorized to view this account.**" Then

with a General run error ion the line.

Any other thoughtful suggestions?

thx

Lor
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,

U are find the inner text **Account 12345678 is invalid or you are not authorized to view this account.** which contains ** at the begining. U are using regular expression in OR. When u are using ** it treats this as a part of regular expression but u want string to start with ** , so in this case use backslash to identify the special character in OR. It will definitely work.

Regards,
Sankalp
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
Sankalp,.

I tried (and many other variations): ...
Code:
        If colWebElements(iCnt).GetROProperty("innertext") = "\*\*Account " & ACCT11 & ".*" Then
        If colWebElements(iCnt).GetROProperty("innertext") = "**Account " & ACCT1 Then
        If colWebElements(iCnt).GetROProperty("innertext") = "\*\*Account.*" Then
        If colWebElements(iCnt).GetROProperty("innertext") = "\*\*Account 12345678.*" Then

... all which returned a General run error.

I then tried (also with different variations: ...
Code:
Browser("Wisdom").Page("WisdomMain").WebElement("innertext:=" & "**Account 12345678 is").Highlight
Browser("Wisdom").Page("WisdomMain").WebElement("outertext:=" & "**Account 12345678 is").Highlight
Browser("Wisdom").Page("WisdomMain").WebElement("innerrtext:= .*Account.*").Highlight
Browser("Wisdom").Page("WisdomMain").WebElement("innerrtext:=" & ACCT1& " .*Account.*").Highlight
Browser("Wisdom").Page("title:=WisdomMain").WebElement("innerrtext:= .*Account.*").Highlight
Browser("Wisdom").Page("title:=WisdomMain").WebElement("innerrtext:=" & ACCT1& ".*Account.*").Highlight
Browser("Wisdom").Page("title:=WisdomMain").WebElement("innerrtext:= \*\*Account " & ACCT1& ".*").Highlight
Browser("Wisdom").Page("title:=WisdomMain").WebElement("innerrtext:=" & "\*\*Account " & ACCT1& ".*").Highlight

...with no luck.

Using the OR, the webelement object Account1 highlights when I View-> Highlight in Application.

Name:Account1
innertext: **Account 12345678 is invalid or you are not authorized to view this account.**
html tag: DIV
Type, Value: Lopcation, 0

Do I need to change the innertext to a RegExp? I did try a variety of ways including:
("innerrtext:=" & "\*\*Account " & ACCT1 & ".*")
Reply
#7
Solved: 11 Years, 3 Months, 3 Weeks ago
I ended up doing: (its not exactly what I want but it works as long as the strActInnerText dosent change)

Code:
strExpInnerText = "**Account " & ACCT1 & " is invalid or you are not authorized to view this account.**"
strActInnerText = Trim(Browser("Wisdom").Page("WisdomMain").WebElement("index:=1", "innerText:=.*is invalid or you are not authorized to view this account.*").GetROProperty("innerText"))

strActInnerText = Right(strActInnerText, 79)

If strExpInnerText = strActInnerText  Then
    msgbox "ReportPass"
Else '
    msgbox "ReportFail"
End If

I ended up getting help using ucValidationControl_pnlValidationMessages instead.

to read:
Code:
strActInnerText = Browser("Wisdom").Page("WisdomMain").WebElement("html id:=ucValidationControl_pnlValidationMessages", "Location:=0").GetROProperty("innerText")
works perfect.

thx
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  regex works but how do i return the found string to a variable jove1776 2 3,422 08-24-2011, 06:17 PM
Last Post: jove1776

Forum Jump:


Users browsing this thread: 1 Guest(s)