Web Click and Script actually does work

On my latest engagement, I needed a web script to go with all of the Citrix scripts I am creating. The web script was giving me some issues with correlation and NT authentication, so I decided to give Web Click and Script a try. I didn’t have much expectation since neither I nor my colleagues have been able to get it to work in the past, but I thought that it would be worth a try in 9.5. Imagine my surprise when it actually worked! This could partly be because the javascript is minimal. That seems to be where C&S hangs.

There is one quirk that I thought I would share. If anyone has some advice, please let me know. It deals with running the script for multiple iterations. In the init section there is the following line:

web_browser("{p_APCURL}",
        DESCRIPTION,
        ACTION,
        "Navigate=https://{p_APCURL}/",
        LAST);

In the Action section the first line is:

web_element("Reports",
        "Snapshot=t6.inf",
        DESCRIPTION,
        "Text=Reports",
        "Tag=TD",
        ACTION,
        "UserAction=Click",
        LAST);

For the first iteration, this runs fine. But when it runs for the second iteration, it fails. When I look at the log it says, “Error -26160: Browser not found” and “There is no context for GUI-based functions. A web_browser(… “Navigate=” …) may be missing, or the context has been reset”

For a little while this puzzled me. But then I saw what it was doing. I had the Run-Time setting set to Similate a New User on Each Iteration and Clear Browser Cache. It looks like the web_element function needs a previous web_browser function to work from. When I cleared those Run-Time options, the script ran fine. So evidently, running as a new user every time cleared the web_browser function in the vuser_init from the memory. So I inserted the following code before the web_element in the Action:

if (atoi(lr_eval_string("{p_IterationCount}")) != 1) {
        web_browser("Home",
            DESCRIPTION,
            ACTION,
            "Navigate=https://{p_APCURL}/Default.aspx",
            LAST);
}

Problem solved. There may be a better solution. If you know of one, let me know.
Tim

What's Next?

Did you enjoy this article? Help spread the word by sharing:

Join the Northway Navigator Club today and get access to restricted content including our best tips and tricks. Membership is free! You will also receive free email updates by registering.

Engage in the conversation and leave a comment:

Scott Moore

About Scott Moore (153 articles)

With over 20 years of IT experience with various platforms and technologies, Scott has tested some of the largest applications and infrastructures in the world. He is a Certified Instructor and Certified Product Consultant in HP’s LoadRunner and Performance Center products. He currently holds HP certifications for ASE, ASC, and CI. A thought leader in the APM space, he speaks regularly at IT conferences and events