WebElement not found in OR - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: UFT / QTP Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions) +--- Thread: WebElement not found in OR (/Thread-WebElement-not-found-in-OR) |
WebElement not found in OR - mv8167 - 03-24-2012 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 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 RE: WebElement not found in OR - rajeevszone - 03-25-2012 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() 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' RE: WebElement not found in OR - rajeevszone - 03-25-2012 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() 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() 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 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' RE: WebElement not found in OR - mv8167 - 03-26-2012 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 RE: WebElement not found in OR - sshukla12 - 03-27-2012 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 RE: WebElement not found in OR - mv8167 - 03-27-2012 Sankalp,. I tried (and many other variations): ... Code: If colWebElements(iCnt).GetROProperty("innertext") = "\*\*Account " & ACCT11 & ".*" 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 ...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 & ".*") RE: WebElement not found in OR - mv8167 - 03-27-2012 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.**" 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") thx |