I am writing a test for a browser application using QTP 11. When a user creates a new customer there are many fields they need to complete, however when the First and Last Name is entered in to webedit boxes I see the string entered but when the you try to save the new customer an error message is shown asking to enter the customers name. If I then manually click in the webedit box, press the space bar and then click delete, the customer will then be saved.
I think that the text is not detected properly due to the fact that copy/paste, right click and other functionality has been disabled in the application which might be causing issue with how QTP interacts with it (all pure guess work).
Has anyone come across a problem with text being entered into a cell where copy/paste has been disabled?
I thought a quick solution to this problem would be to automate that process of clicking in the cell and then use the SendKeys method to press the space bar and backspace. Here is the code that I am running:
Set objpage = Browser("TextForExample").Page("TextForExample")
Set WshShell = CreateObject("WScript.Shell")
If I run the above code as an action on its own (either from QTP or using cscript from cmd line) there is no problem and the keystrokes are sent and the customer can be created. However if I call the action as part of another script, e.g. Runaction "EnterCustomerData", RunAction "SendKeys", the webedits are clicked but it appears that sendkeys no longers works and I can see that the key strokes are not performed on the webelement.
Variations on the above that I have tried:
Running above as a function
Placing wait(3) after each line of the above code in case of a synchronization problem
Placing code in to the top most action, e.g. instead of:
Runaction "EnterCustomerData", RunAction "SendKeys"
I had: Runaction "EnterCustomerData", Set objpage = Browser("TextForExample").Page("TextForExample"), Set WshShell = CreateObject("WScript.Shell"), etc
Has anyone come across this problem before and more importantly did you find a fix/workaround/explanation?
Any help would be greatly appreciated, this has had me scratching my head for a couple of days now!
I had tried Fireevent as well as Object.Focus and it had the same problem.
Changing the ReplayType has fixed it and now I don't need to use Sendkeys, instead I switch to ReplayType = 2 just before setting the webedit boxes and then back, now the customer is created without any issues.
Thanks for the help, it was driving me crazy and I think that will definitely come in handy in the future!