Selenium interacting with Pega UI. Unable to consistently interact with elements
Hi, we are interacting with Pega UI using Selenium and Java for the purposes of automation .
In building a simple script we have correctly identified the elements either by ID or by Xpath. We then send values to be stored into a text box and then move onto the next element
During run-time the results are inconsistent as sometimes values to be stored in one field are then stored into another one. Or sometimes the value flashes up briefly on the screen and then seems to be cleared by something else. Reset by Javascript?
My research indicates that Pega is ajax intensive and it is that activity that is interrupting the Selenium script during runtime. The solution seems to be either putting in messy sleep commands or building a helper class that tries to force the value to be inserted into the field. Neither of these are ideal.
When we try and incorporate a class that is supposed to wait for Ajax interaction to complete it still fails to work. I've included the example below. Is the reason that this solution does not work down to the setting of the Pega-Rules pzPegaSUT. Currently ours is set to false. Will setting it to true allow us to check for background Ajax to be complete before interacting with an element in a consistent manner?
Are there any other impacts of setting this value? Or is there a better solution other then leaving sleep commands in the code? One other poster indicated he had a solution then decided to not share it with the community?
Hi, we are interacting with Pega UI using Selenium and Java for the purposes of automation .
In building a simple script we have correctly identified the elements either by ID or by Xpath. We then send values to be stored into a text box and then move onto the next element
During run-time the results are inconsistent as sometimes values to be stored in one field are then stored into another one. Or sometimes the value flashes up briefly on the screen and then seems to be cleared by something else. Reset by Javascript?
My research indicates that Pega is ajax intensive and it is that activity that is interrupting the Selenium script during runtime. The solution seems to be either putting in messy sleep commands or building a helper class that tries to force the value to be inserted into the field. Neither of these are ideal.
When we try and incorporate a class that is supposed to wait for Ajax interaction to complete it still fails to work. I've included the example below. Is the reason that this solution does not work down to the setting of the Pega-Rules pzPegaSUT. Currently ours is set to false. Will setting it to true allow us to check for background Ajax to be complete before interacting with an element in a consistent manner?
Are there any other impacts of setting this value? Or is there a better solution other then leaving sleep commands in the code? One other poster indicated he had a solution then decided to not share it with the community?
public static void waitForJQueryLoad() {
//Wait for jQuery to load
ExpectedCondition<Boolean> jQueryLoad = driver -> ((Long) ((JavascriptExecutor) jsWaitDriver)
.executeScript("return jQuery.active") == 0);
//Get JQuery is Ready
boolean jqueryReady = (Boolean) jsExec.executeScript("return jQuery.active==0");
//Wait JQuery until it is Ready!
if(!jqueryReady) {
System.out.println("JQuery is NOT Ready!");
//Wait for jQuery to load
jsWait.until(jQueryLoad);
} else {
System.out.println("JQuery is Ready!");
}
}