Monday, May 16, 2011

How to use key strokes in QTP?


'Problem: Sometimes it happened that QTP is not recognizing the objects. Can i use keyboard strokes to click any of the link and Navigate the different parts of open application.

'Solution: 
'Use of KeyStroke on Active Browser/Window
Set Obj=CreateObject("WScript.Shell")
wait 2
Obj.Run "http://www.google.com"
wait 2
     Obj.SendKeys "{Enter}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
     Obj.SendKeys "{Enter}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
  Obj.SendKeys "{Enter}"
         
'The above code will
1.  Launch "Google.com"
2.  Click on link "Advanced Search"
3.  Click on link "Google Instant" within Advanced Search Page

4 comments:

  1. I have java application, I need to test object with tab/enter. I have to focus object and move with "shift"+"tab" and then "tab" to focus the object for pressing the "enter".
    My code works fine but with a loop its stuck doing the Tab/Enter. I tried with object.refresh/wait time/WaitProperty/sync while moving the next object but nothing makes work properly. If I have 60 iterations, there are 2/3 will miss. Is there any solution? Please.

    ReplyDelete
  2. SWIFT Interview questions on

    http://testwithus.blogspot.in/p/swift.htm

    For selenium solution visit
    http://testwithus.blogspot.in/p/blog-page.html

    QTP Interview Questions.

    ReplyDelete
  3. SWIFT Interview questions on

    http://testwithus.blogspot.in/p/swift.htm

    For selenium solution visit
    http://testwithus.blogspot.in/p/blog-page.html

    QTP Interview Questions.
    http://testwithus.blogspot.in/p/qtp-questions.html


    ReplyDelete
  4. Thanks for your informative article!! Your article on using key strokes will help students and testing professionals to solve the complications.
    qtp training chennai

    ReplyDelete