Quantcast
Channel: LoadRunner Practitioners Forum topics
Viewing all articles
Browse latest Browse all 3978

[Knowledge Sharing] How to prevent confirm and alert boxes from showing

$
0
0

Hi,

I had a support case recently with a customer who is using TruClient IE 11.52. They face an issue that is reproduced on certain machines and was resolved in 12.0x. For some reason TruClient IE does not perform click on Confirm/Alert boxes causing the script to hang during replay.

I wanted to share an easy workaround - prevent the confirm/alert box from showing. I have seen this issue more than once and in all cases the workaround below didn't affect the functionality of the application under test

 

Script before the workaround:

  1. ..... script logic before relevant part
  2. Step A that triggers pop up box(es).
  3. Click OK on confirm box
  4. Click OK on alert box
  5. .... script logic after relevant part

 

Workaround

  1. Add "Evaluate JavaScript" step before the step that triggers the pop-ups with the following code in it

 

// Save original alert and confirm functions in order to restore them later

var browserAlert - window.alert;

var browserConfirm = window.confirm;

 

// Override browser alert and confrm behavior not to issue a pop-up

window.alert = function() { returntrue; }

window.confirm = function() { returntrue; }

 

2. Add "Evaluate JavaScript:" step after the step that triggers the pop-ups with the following code in it

 // Restore normal behavior of confirm and alert boxes

window.alert = browserAlert;

window.confirm = browserConfirm;

 

Script after the workaround

  1. ..... script logic before relevant part
  2. Evaluate JavaScript to prevent pop up boxes from showing
  3. Step A that triggers pop up box(es).
  4. Evaluate JavaScript to restore pop up boxes
  5. .... script logic after relevant part

 

Notice that there is no need in the Click OK steps anymore since the browser does not show them

 

Hope it helps

 Shlomi


Viewing all articles
Browse latest Browse all 3978

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>