Back to Blog

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

Back to Blog