Benone Absent Member.
Absent Member.
1046 views

F5 refresh emulation

Hello,

I need your help on the below. We need to test a scenario where the user hits on the refresh button (F5) on the home page of the application continuously for 5 times(gap between each F5 hit should be less than 1 second) so that an error message is displayed.

Could you please let me know which function call or keyword can be used to emulate the above piece. Any possible ways to achieve will be helpful

Regards, S

0 Likes
2 Replies
Micro Focus Contributor
Micro Focus Contributor

RE: F5 refresh emulation

Hi Benone,

If you are using the Browser driven load testing approach within Silk Performer - Web Browser Driven (AJAX) - there is a named key available for the BrowserTypeKeys function which will allow you to simulate the F5 key on your keypad, which is generally the refresh key for a Browser. Copy the following syntax into a browser driven script to see refresh action taking place.

BrowserStart(BROWSER_MODE_DEFAULT, 960, 689);
BrowserReplayCompatibility(SP_15_5);
wnd1 := BrowserGetActiveWindow("wnd1");
BrowserNavigate("http://demo.borland.com", "Navigate_http://demo.borland.com (#1)");
ThinkTime(4.5);
BrowserClick("//a[@textContents='Test Sites']", BUTTON_Left, "Click, A, textContents=Test Sites (#1)");
BrowserClick("//a[@textContents='ShopIt V 6.0']", BUTTON_Left, "Click, A, textContents=ShopIt V 6.0 (#1)");
BrowserClick("//a[@textContents='Join the experience!']", BUTTON_Left, "Click, A, textContents=Join the experience! (#1)");
ThinkTime(2.1);
BrowserClick("//input[@name='name']", BUTTON_Left);
ThinkTime(3.7);
BrowserSetText("//input[@name='name']", "TestUser");
BrowserTypeKeys("//body[@spellcheck='false']", "<F5>"); // Here the refresh will take place
BrowserClick("//input[@name='New-Name-Button']", BUTTON_Left, "Click, INPUT, name=New-Name-Button (#1)");

If I exclude the BrowserTypeKeys function from my script, what would occur is that TestUser string is entered into the text box and the user is then brought to the main page of the application (through the BrowserClick / New-Name button). Because I have included the BrowserTypeKeys which simulates the F5 key, after the data is entered, the browser is refreshed, thus data entered into the text box will disappear and navigation to the main page will not take place (as the system is expecting a name to be entered - which never was).

The key to successful implementation of this function is to ensure that you have a valid xpath locator string which can be used for the refresh simulation. Find a static element on the page you wish to carry out the refresh upon, i.e. an image or a piece of text. The xpath locator string can be retrieved through a browser driven recording and by interacting with the element, i.e. clicking - Silk Performer will record a function which contains the path. Within the subsequent script, include 5 BrowserTypeKeys("xpath", "<F5>"); functions within your script and insert the recorded xpath.

This should recreate the behaviour you require.

Regards

Paul

0 Likes
Highlighted
Micro Focus Contributor
Micro Focus Contributor

RE: F5 refresh emulation

Hi Benone,

Just adding to my previous response, there is also the BrowserReload function which you potentially use. Further information on both functions BrowserTypeKeys (including named keys) and BrowserReload can be found within the Silk Performer documentation - SILK PERFORMER | HELP | CONTENTS.

Regards

Paul

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.