Tuesday, January 24, 2012

How to use Open2Test keyword with QTP

Open2Test is add-on style keyword-driven framework which aims to replace test script with excel defined set of keywords.

http://www.open2test.org/

Today, I will explain how to define the keyword. The reason I'm posting such information is because Open2Test documentation is the worst documentation I've ever read. I know it's open source but lacking responsibility to guide users to the point that they can actually "use" it.

NOTE: Open2Test does not provide the forum to discuss about the framework but instead they have support email which you don't get response at all. (I sent 2 emails regarding to keyword definition etc and it has been a week since)

Since I used QTP to do my research, I will show how the keyword should look like.

I assume you have basic knowledge of how QTP works.

Object Repository

What makes QTP powerful tool is that it has Object Repository where you can store test object and all the test uses the repository. In the test script, you use test object name in the repository to refer to actually object such as DOM Element or Windows Object. Open2Test uses the test object name in the Object Repository.

For instance, in the QTP Object Repository, there is test objects of a website.

Browser --> myBrowser
                 |
                 |---Page --> myPage
                        |
                        |---Frame --> view
                                      |
                                      |----->WebEdit --> FirstName (this is textbox)

Now Open2Test keyword should look like below in order to type into the textbox.

r wait 2
r context browser;myBrowser page;myPage::frame;view
r perform textbox;FirstName set:hello world

The first row - wait for 2 second

The second row - move focus to frame inside of page inside of browser

The third row - type "hello world" into the textbox.

I had to read source code of Open2Test QTP web to find out this. The documentation does not tell me how I should define context keyword. Anyway, I confirmed that above works just fine. If anyone has an issue please let me know I may be able to help

Thursday, January 12, 2012

Call to jQuery dialog will execute external Javascript!

I came across this while debugging jsp page. Totally took my few hours of scratching my head til bleed.

The gotcha is when included jsp imports javascript and if the jsp is within jQuery dialog, the imported javascript is also read by browser once.

Maybe easier to show the code

foo1.jsp



    

        /* NOTE: jQuery dialog import is omitted for simplicity */

        
    

    
        

Hello World!


foo2.jsp


    
         
    
    
    

alert.js

alert("alert");

What happen here is when the button is clicked, dialog is displayed but before that, alert message from alert.js is executed!

This proves that dialog section includes javascript, it will get executed