How to handle this popup? - watir

The above pic consist of my popup image, Can anyone guide me how to handle this pop up?

This popup can be treated like any other alert. You can confirm the dialog (ie click Leave) using:
browser.alert.ok
If you do not know if the popup will or will not be there, you can add a check for its presence:
browser.alert.ok if browser.alert.present?
If this does not work, an alternative is to disable the function being called on unload. Make sure that you override the function before it is triggered.
# Remove the function
browser.execute_script("window.onbeforeunload = null")
# Then trigger the action that leaves the page
browser.link.click

Related

xpages - enableModifiedFlag -> possible to prevent default dialog at beforeunload event?

For my xpages app I want to set the enableModifiedFlag to true to have a dirty form functionality to check if changes are made to a page.
I tried to avoid that the default warning message will appear when moving away from the page by setting the page to not dirty but this not prevent/hinder that the default dialog appears. what am I doing wrong?
window.addEventListener('beforeunload',(event) =>{
var isdirty = XSP._isDirty();
console.log("check -> is dirty? " + isdirty);
if(XSP._isDirty()){
console.log("set dirty to false to avoid ugly standard alert dialog");
XSP._setDirty(false,"");
//add this to prevent default behaviour e.g. open another page
event.preventDefault();
//add here code to present a more fancy bootstrap dialog
//XSP.openDialog("dirtyDialog")
return false;
}
});
Haven't done exactly what you do...
However, if on a button you want to "cancel" then you only need to call
XSP._setDirty(false,"");
prior to navigating away. No need to call event.preventDefault() in that case. So I'm guessing that the default code is called prior to your "before unload" event - perhaps you can try and see if you could intervene a little before or somehow rethink the approach.
Perhaps I don't fully understand what you want to obtain when having this functionality but avoiding to use it when leaving the page - or is this just a test example?
/John

How to get the hand/controller that pressed a button

I would like to know, just by subscribing to the Interactable OnClick event, if I pressed the button with my left or right hand. Would that even be possible without passing this information along with the OnClick event?
The button has quite the logic to go through until it decides to accept a click request, so replicating all of that via global listener is not feasible.
Is it possible to get that information OnClick from somewhere else? Is it possible to query the potential click sources for who that was?
Without altering the Interactable class the only way I found was to query the FocusProvider for the active pointer, which must have been the one pressing the button (in my case):
https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/Input/Pointers.html
https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/Input/Controllers.html
Setup your controllers, take note of the axis name, in code you can do something like this in any GameObject's update loop:
if (Input.GetAxis("Axis1D.PrimaryHandButton") > 0.5f) {
// this axis (button) is pressed do something
}

How to pass value to confirmation popup from custom screen

I need to fire Complete Order action of Production Order Maintenance screen from my custom screen, the issue is, when action is fired am getting an error saying, "Are you sure want to complete the order" this is the same confirmation message we get when we do from Production Order Maintenance screen as well, my question is, how we can avoid this popup or how i can pass value to this popup from my custom graph.
ProdMaintGraph.ProdMaintRecords.Current = ProdItem;
ProdMaintGraph.completeorder.Press();
You can try it like this!
ProdMaintGraph.ProdMaintRecords.Cache.Graph.Views["ProdMaintRecords"].Answer = WebDialogResult.Yes;
If in the popup form Message Buttoin is Yes, or one is this values which are None,OK ,Cancel,Abort,Retry ,Ignore,Yes,No

Test quickly changing scenario using selenium web driver in nodejs

I have a button which triggers a rest call and upon click of that button until the rest call triggers I disable the button.
I am writing a test case using selenium web driver and nodejs
button = driver.findElement(By.class("btn"));
await button.click();
console.log(await button.isEnabled()) //outputs true
But I can see that the button is being disabled and I am sure Iam selectingthe correct button the findElement statement.
The documentation for .isEnabled() says:
Is the element currently enabled or not? This will generally return true for everything but disabled input elements.
So what you are seeing is expected behaviour.
To test your scenario, you will need the following approach:
click your button
click the same button again
the second click you are expecting to fail, so you will have to wrap it in whatever is the node.js equivalent of try..catch (sorry, I'm a Java guy)
inside of the catch, set a variable to true
afterwards test the variable has been set
The scenario you have described is to click a button, verify it becomes disabled, and then verify it becomes enabled. There are probably a few ways to do this. I'm looking at the documentation and here is one way:
button = driver.findElement(By.class("btn"));
button.click();
driver.wait(until.elementIsDisabled(button));
driver.wait(until.elementIsEnabled(button));
If the button never becomes disabled, an exception will be thrown. If the button never becomes reenabled, an exception will be thrown. So, the fail condition is either one throwing an exception. The pass condition is no exceptions.
NOTE: disabled and enabled, in Selenium terms, is generally referring to an INPUT tag. If your button is not an INPUT tag, then this won't work. You will need to detect some CSS style being applied/removed to determine disabled/enabled.

How to identify a button click in coded UI Customised code

In UIMAP.CS file in both the Recorded method and assertion method, I am not able to identify the button click.
Is there any way I can get hold of the button click event?
I am able to get hold the button in to a UITESTCONTROL variable but the options I was able to see are "exists", "enabled","name" etc...
I tried checking it with assertions too when I dragged the cross hair on to the clicked button , assertions are generated only for checking the existence,correctness of text and name but not the events occured on it..
Please help in this regard..
Please make sure that the Control/Object on which you want to use the Click operation is a button and not any Web Element or control which does not support the Click operation.
Once verified, you can do the following:
Record a New Session and while recording click on that button, stop your recording.
Open the UIMap.cs and navigate to that button control. The intellitrace would show you all the available options for that control.
Thanks
Nikhil

Resources