Micro Focus QTP (UFT) Forums

Full Version: QTP Not Recognizing WebElement
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

I have a strange issue with QTP.
Scenario

I have to enter a value in a webedit and click on save button
I recorded the script and while running the script when it enters the value and goes to the next line to save it, the button is not visible
and it throwing an error object not found.
The way they coded the button is after entering the value in the webedit and click on any area that save button would vanish.
Could someone please let me know how to code this scenario.

Thanks in advance!!!
quickest advice I can offer is try adding a micTAB to the value or rerecord and after you enter the data hit the tab key, then click save.

they probably have a javascript validation onclick event that needs to fire in order to activate the save button. Look in the QTP document as well, there is a way to trigger events, but the tab key is usually the easiest.

Hope this helps.
I added micTab and it did not work either....
Also WebEdit does not support Type...
Is there any other way I can type letters on the webedit and make the focus stay on the Save button?

Thanks,
Sathiya
Sathiya,

Try useing FireEvent
Code:
Browser("").Page("").WebButton("Save").FireEvent "onmouseover"

and kindly let me know this solve your problem.
Hi Arun,

I have a WebEdit and when I run the below code the Webedit is not getting enabled, and only if I input a value on the WebEdit then the Save button would get enabled.

Code:
Browser("").Page("").WebEdit("WebEdit").Set "test3"

The below line did not work
Browser("").Page("").WebButton("Save").FireEvent "onmouseover"


Thanks,
Sathiya
The thing is that you have to figure out what javascript event is enabling the button. It is usually onchange, or onblur for the WebEdit. It could also be onkeydown, onkeypress, or onkeyup. When you are entering the value manually, the behavior can give you a clue as to what event to fire. If the Button does not enable until you leave the field, then it is onblur. If the button becomes enabled as you type, it could be any one of the others.

If you can't inspect the code to figure it out, which would be the most accurate way of determining what event enables the button, you can fire all the events and figure it out with trial and error. Try the below code and comment out each line and run until you figure out what event enables the button.

Code:
Browser("").Page("").WebEdit("WebEdit").Set "test3"
Browser("").Page("").WebEdit("WebEdit").FireEvent "onchange"
Browser("").Page("").WebEdit("WebEdit").FireEvent "onblur"
Browser("").Page("").WebEdit("WebEdit").FireEvent "onkeydown"
Browser("").Page("").WebEdit("WebEdit").FireEvent "onkeypress"
Browser("").Page("").WebEdit("WebEdit").FireEvent "onkeyup"

There are other events that could do it (like Sathiya pointed out, it could be an event on the WebButton like onfocus, but I doubt it). However, the event is most likely one of the above. More information: http://www.w3schools.com/jsref/dom_obj_event.asp

You can also try changing the ReplayType for the WebPackage:
Code:
Setting.WebPackage("ReplayType")=2
Browser("").Page("").WebEdit("WebEdit").Set "test3"
Setting.WebPackage("ReplayType")=1
Hi Sathiya,

Sorry i am not yet clear with your problem...
can you please elaborate step by step...