Find Web Elements using QTP
Does anyone know how to find web elements in a web page, without using the name of an element or its id? Just specify that the element is a textbox or a textarea and say that it is the first textbox on the page or something like that. This will help me in automation testing where I have to test the existence of web elements and I have to find them as quickly as I can. I do not know if it is possible this way of looking for web elements. I am using QTP. If anyone has an idea or can help, I thank you in advance.
Re: Find Web Elements using QTP
You could use the index but it will only work for static webpages.
The paradox of the WebElement is the usual thing you want to do with a WebElement is capture its innerText and the best way to do this is to identify it by it's innerText & html tag.
I have been lucky once where the dynamic text in the WebElement was in a header, it had an html tag of H1 and it was the only WebElement using this tag. I captured it's innerText by:
theText=Browser("micClass:=Browser").Page("micClas s:=page").WebElement("html tag:=H1").GetROProperty("innerText")