Test is failing, gives error - cucumber.runtime.CucumberException: Arity mismatch: - cucumber

I am seeing below error in console log.
cucumber.runtime.CucumberException: Arity mismatch: Step Definition 'com.sfg.wef.steps.PolicyOwnersLandingSteps.inOwnerLandingPageIClickButtonOrIClickCompanyContractAndStayOnChecklistIfAny(String,String) in file:/C:/dev/web-external-framework/wef-tests-mma/target/test-classes/' with pattern [^in owner landing page I click (.) button or I click company (.) contract/policy (.*) and stay on modal informational page if any$] is declared with 2 parameters. However, the gherkin step has 3 arguments [Partial Withdraw, company, policy number].
Please guide!

The error means you are passing in and writing out an inconsistent number of captured arguments from your regex.
Looking at your snippet (Albeit it is quite hard), it seems as though you're mixing CukeExp and Regexp. Could you paste the code-snippet here and I can try triage for you.
Remember if you're using anchors ^ and $ you need to use regexp. So start / end your statement with / /. However CukeExp which is newer and designed to be easier to use, requires you to start and end with a " or '

Thank you Luke Hill for your response. here is the code.
#And("^in owner landing page I click (.) button if available else I click company (.) contract/policy (.*)$")
public void inOwnerLandingPageIClickButtonIfAvailableElseIClickCompanyContractPolicy(String buttonName,
String company,
String contractPolicyId) {
inOwnerLandingPageIClickButtonOrIClickCompanyContractAndStayOnChecklistIfAny(buttonName, contractPolicyId);
// in service-capture modal, click through any checklist messages to proceed through flow
assertSCLandingPageChecklistMessages(contractPolicyId, buttonName);
}
// when service-capture modal opens, if there are any checklists or informational message displayes where user
// has to decide to proceed by clicking ok or yes - stay on that page and do not click ok/yes
#And("^in owner landing page I click (.*) button or I click company (.*) contract/policy (.*) and stay on modal informational page if any$")
public void inOwnerLandingPageIClickButtonOrIClickCompanyContractAndStayOnChecklistIfAny(String buttonName,
String contractPolicyId) {
Boolean selectedSC;
Boolean selectContractPolicy;
getContractPolicyValues(contractPolicyId);
// isCompanyClient();
Assert.assertTrue(String.format("%s is not eligible to see %s button", contractPolicyId, buttonName),
euiPolicyownerLanding.isEligibleForServiceCaptureButton(buttonName, contractPolicyId, policySummary));
// if landing page displays button then click it, else click on contract/policy from list to go to Summary
// details page and if Summary page displays button then click it
selectedSC = euiPolicyownerLanding.clickServiceCaptureButtonOnPage(buttonName, "landing");
if (!selectedSC) {
Assert.assertTrue(euiPolicyownerLanding.missingContractPolicy(contractPolicyId));
selectContractPolicy = euiPolicyownerLanding.selectContractPolicyFromListOnLandingPage(contractPolicyId);
if (selectContractPolicy) {
waitForPageLoadComplete(Waf.pageLoadMaxWaitTimeSeconds);
waitForPageReadiness();
selectedSC = euiPolicyownerLanding.clickServiceCaptureButtonOnPage(buttonName, "summary");
}
}
if (selectedSC) {
if (!switchToSpecificWindow("servicecapture")) {
euiPolicyownerLanding.selectContractPolicyFromListOnMultiPolicyPage(contractPolicyId);
if (!switchToSpecificWindow("servicecapture")) {
selectedSC = euiPolicyownerLanding.clickServiceCaptureButtonOnPage(buttonName, "summary");
if (!selectedSC) {
ApplicationError.handleApplicationError();
Assert.fail(String.format("After clicking %s button for %s, was unable to switch to %s window",
buttonName, contractPolicyId, buttonName));
}
}
}
} else {
Assert.fail(String.format("Unsuccessful attempt to click %s button for %s, was unable to switch to %s window",
buttonName, contractPolicyId, buttonName));
}
switch (buttonName.toLowerCase()) {
case "partial withdraw":
SystematicWithdrawalSteps.currentContractPolicyID = contractPolicyId;
break;
default:
Assert.fail(String.format("Unimplemented button %s", buttonName));

Related

How do I clear the input of a Smart Panel dialog (PXFilter)?

I have created a smart panel in a custom screen to ask for user input that is used to facilitate moving stock from normal inventory into an isolation area. My original smart panel example that I always use is the Copy Order in the SOOrderEntry graph (SO301000). In this case, I need to do a bit of validation, and the user may very well decide to close the smart panel and update the document in the screen before reopening the smart panel again. If the user clicks the cancel button, I need the smart panel to reset back to defaults every time it is opened.
I thought this might be handled in the ASPX screen definition, but I can't find the right setting for the form itself. I use AutoRefresh on selectors to refresh every time they are opened, but I need the form itself to do the same and refresh back to default every time it is opened. The desired behavior DOES occur automatically when I navigate to another record of the graph's primary DAC, but I cannot seem to force the smart panel to refresh automatically every time it is opened. I looked at the various options for the form in ASPX, but I overlooked it if it is there.
Similarly to CopyOrder on SOOrderEntry, here is my code sample from my graph.
public PXFilter<StockParamFilter> stockparamfilter;
#region AddFromStock
public PXAction<MyTag> addFromStock;
[PXUIField(DisplayName = Messages.AddFromStock, MapEnableRights = PXCacheRights.Insert, MapViewRights = PXCacheRights.Insert)]
[PXButton]
protected virtual IEnumerable AddFromStock(PXAdapter adapter)
{
MyTag tag = Tags.Current;
if (tag?.TranRefNbr != null)
{
throw new PXException(Messages.TagAlreadyReceived);
}
MyTagEntry graph = PXGraph.CreateInstance<MyTagEntry>();
WebDialogResult dialogResult = stockparamfilter.AskExt(setStockStateFilter, true);
if (dialogResult == WebDialogResult.OK || (IsContractBasedAPI && dialogResult == WebDialogResult.Yes))
{
// My Business Logic Here
}
return adapter.Get();
}
#endregion
#region CheckStockParams (OK Button in Smart Panel)
public PXAction<MyTag> checkStockParams;
[PXUIField(DisplayName = "OK", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXLookupButton]
public virtual IEnumerable CheckStockParams(PXAdapter adapter)
{
return adapter.Get();
}
#endregion
#region setStockStateFilter
private void setStockStateFilter(PXGraph aGraph, string ViewName)
{
checkStockStateFilter();
}
#endregion
#region checkStockStateFilter
protected virtual void checkStockStateFilter()
{
// My Business Logic Here to set bool enableStockParams = ???
checkStockParams.SetEnabled(enableStockParams);
}
#endregion
This seems like something I did in the past, but I cannot seem to locate the code. I think it is related to stockparamfilter being a PXFilter instead of a PXSelect (or SelectFrom).
I have tried stockparamfilter.ClearDialog() with no luck. I have tried stockparamfilter.RequestRefresh() with no luck. I even tried stockparamfilter.DeleteCurrent() which seemed to work when I hit Cancel, but then my code did not execute when I hit OK. I also seemed to get the desired results when I used stockparamfilter.Cache.SetDefaultExt<StockParamFilter.locationID>(filter); on every field, until I hit OK which did nothing. It's like every time I try to manipulate the filter, I break the smart panel without any errors in the trace. In fact, here is the list of what I tried unsuccessfully:
StockParamFilter filter = stockparamfilter.Current;
stockparamfilter.View.Clear();
stockparamfilter.View.RequestRefresh();
stockparamfilter.Cache.Clear();
stockparamfilter.View.RequestRefresh();
stockparamfilter.View.RequestFiltersReset();
stockparamfilter.DeleteCurrent();
stockparamfilter.ClearDialog();
stockparamfilter.Cache.SetDefaultExt<StockParamFilter.locationID>(filter);
stockparamfilter.Cache.SetDefaultExt<StockParamFilter.toLocationID>(filter);
stockparamfilter.Cache.SetDefaultExt<StockParamFilter.qty>(filter);
stockparamfilter.Cache.SetDefaultExt<StockParamFilter.lotSerialNbr>(filter);
stockparamfilter.Cache.SetDefaultExt<StockParamFilter.origRefNbr>(filter);
What is the ASPX code or C# Code that will let me reset the smart panel to defaults?
A big thanks to Hughes Beausejour at Acumatica for the offline assist. Posting solution for anyone else that may have this issue.
First, it is important to understand that AskExt generates 2 passes of the code. The first pass prompts the smart panel. Upon response to the smart panel, the code executes again, but in this second context skips the ask. With that in mind, the reason for my code not working became clear, as Hughes explained to me.
To execute the code when the form is initialized, that code must be executed before the ask occurs. Otherwise, the form is presented and then the initializing code is executed too late. Additionally, it must be conditioned such that it only fires when the smart panel was not given an OK response by the user. (Not realizing the code executes twice, I was unaware that I was resetting the fields on both passes. When I could get the form to reset, the subsequent processing would fail becuase I was resetting it on that pass as well.) Following that code, the AskExt can be used to present the form along with the normal processing of the user response.
My code, to show the working example, is as follows:
StockParamFilter filter = stockparamfilter.Current;
// If the user response is anything except an affirmative, default the fields
if (!(stockparamfilter.View.Answer == WebDialogResult.OK || (IsContractBasedAPI && stockparamfilter.View.Answer == WebDialogResult.Yes)))
{
stockparamfilter.Cache.SetDefaultExt<StockParamFilter.locationID>(filter);
stockparamfilter.Cache.SetDefaultExt<StockParamFilter.toLocationID>(filter);
stockparamfilter.Cache.SetDefaultExt<StockParamFilter.qty>(filter);
stockparamfilter.Cache.SetDefaultExt<StockParamFilter.lotSerialNbr>(filter);
stockparamfilter.Cache.SetDefaultExt<StockParamFilter.origRefNbr>(filter);
}
// Present the Smart Panel Dialog (happens only on the 1st pass - AskExt causes the code to execute twice)
WebDialogResult dialogResult = stockparamfilter.AskExt(setStockStateFilter, true);
// If the response was affirmative, execute the business logic
if (dialogResult == WebDialogResult.OK || (IsContractBasedAPI && dialogResult == WebDialogResult.Yes))
{
// Do Business Logic Based On User Response In Smart Panel
}

how do I customize dialog to the detail page of an answer set?

In a dialog file like
dialog (Result) {
match: Content (this)
template("Welcome!")
}
where Content is an an answer set and the user proceeds from browsing the answer set to each detail page, how do I customize so that the dialog is different for each mode -- list, summary, detail?
I am looking to do something along the lines of if mode = Detail then template = Content.text
You can add this setting to your capsule.bxb file.
runtime-version (2) {
overrides {
allow-dialogs-on-detail-pages (true)
}
}
In your result-view, you can define your details dialog in the message section. For example:
message {
// A single result?
if (size(this) == 1) {
template (Details Dialog!!!)
}
}

CodedUI - Check if a control exists or not

I have a web page with a login button, to get to the site you simply click the button. This is easily done by writing this:
//Click the Login button
UITestControl Login = new UITestControl(Browser);
Login.TechnologyName = "Web";
Login.SearchProperties.Add("ControlType", "Button");
Login.SearchProperties.Add("Type", "Submit");
Login.SearchProperties.Add("DisplayText", "Log In");
Mouse.Click(Login);
HOWEVER, after you login the first time, you remain logged in for an hour (auto log out if idle for over an hour). If you access the site more than once within an hour, there will be no login button since you are still logged in so everytime I run my test, it will error right away because it won't find the control.
I hope that makes sense, here is a synopsis:
First time to site - Login screen appears, click login button, gain entry
Subsequent times to site - No login screen appears,no login required
so basically I want to say, "If there is a login button, click it then do the next thing, if no login button, then do the next thing"
There is a TryFind() method which you can use.
UITestControl Login = new UITestControl(Browser);
Login.TechnologyName = "Web";
Login.SearchProperties.Add("ControlType", "Button");
Login.SearchProperties.Add("Type", "Submit");
Login.SearchProperties.Add("DisplayText", "Log In");
// TryFind() returns true if it's in the Markup somewhere, even if hidden.
// By testing Width > 0 && Height > 0, we make sure it is visible.
// If it were Hidden and we did not use TryFind() before checking Height
// or Width, there would be an exception thrown.
if(Login.TryFind() && Login.Width > 0 && Login.Height > 0)
{
Mouse.Click(Login);
}
There is also the TryGetClickablePoint method that you can use instead of looking for width and height.
Point p;
if(Login.TryGetClickablePoint(out p))
{
Mouse.Click(Login);
}
There's a .Exists method for all UI controls
var lastPageButton = new HtmlHyperlink(parent);
lastPageButton.SearchProperties[HtmlHyperlink.PropertyNames.Title] = "Login";
lastPageButton.SearchProperties[HtmlHyperlink.PropertyNames.Class] = "YourClassHere";
if (lastPageButton.Exists) Mouse.Click(lastPageButton);
//Other work

Implementing a blocking modal view/dialog like in Windows Forms - is it possible?

In short:
I want to show a view or action sheet and only continue code execution after the user has dismissed the view / sheet. So: line one shows the view, line two reads some result variable.
In detail why I would need this:
I'm porting a Windows Forms application over to the iPad. The original implementation has a communication class which uses a web service to communicate with the server. It offers a couple of methods to get data. Conveniently it checks prior to each call if the user still has a valid connection or if he has to re-enter his password for security reasons.
If the password is required, the .NET class shows a modal dialog which blocks any further code executio and if the password was entered, retries the last call it has made before showing the dialog.
Now using CocoaTouch I'm facing a problem. I replaced the code that shows the dialog with a UIActionSheet. Works great but code execution continues immediately, whereas in Windows Forms it is blocked (the next line in Windows Forms after showing the dialogs is to read the entered password from the dialog) until the dialog has been closed.
I tried a Thread.Sleep() until the user dismisses the UIActionSheet but the Thread.Sleep() also blocks the main loop and my view won't even be drawn.
The alternative I currently see is to change all methods in the already working class and give them a return value: if password required, handle it, then retry.
But this means that all over my code I will have to add these checks because at any given moment the password might be needed. That's why it is nested in communication class in Windows Forms.
Any other ideas?
René
Yes, it is possible.
To do this, what you can do is to run the mainloop manually. I have not managed to stop the mainloop directly, so I instead run the mainloop for 0.5 seconds and wait until the user responds.
The following function shows how you could implement a modal query with the above approach:
int WaitForClick ()
{
int clicked = -1;
var x = new UIAlertView ("Title", "Message", null, "Cancel", "OK", "Perhaps");
x.Show ();
bool done = false;
x.Clicked += (sender, buttonArgs) => {
Console.WriteLine ("User clicked on {0}", buttonArgs.ButtonIndex);
clicked = buttonArgs.ButtonIndex;
};
while (clicked == -1){
NSRunLoop.Current.RunUntil (NSDate.FromTimeIntervalSinceNow (0.5));
Console.WriteLine ("Waiting for another 0.5 seconds");
}
Console.WriteLine ("The user clicked {0}", clicked);
return clicked;
}
I think this approach using async/await is much better, and doesn't suffer from freezing the app when rotating the device, or when the autoscrolling interferes and leaves you stuck in the RunUntil loop forever without the ability to click a button (at least these problems are easy to reproduce on iOS7).
Modal UIAlertView
Task<int> ShowModalAletViewAsync (string title, string message, params string[] buttons)
{
var alertView = new UIAlertView (title, message, null, null, buttons);
alertView.Show ();
var tsc = new TaskCompletionSource<int> ();
alertView.Clicked += (sender, buttonArgs) => {
Console.WriteLine ("User clicked on {0}", buttonArgs.ButtonIndex);
tsc.TrySetResult(buttonArgs.ButtonIndex);
};
return tsc.Task;
}

How to "chain" modal dialogs in YUI 2?

I have a modal dialog box presented in Yahoo UI. The user selects a value from dialog "A", and then I want to present another modal dialog box to collect some more data in dialog "B".
I have been using the YAHOO.widget.Dialog successfully. The problem seems to be that you can't initiate dialog window "B" from the handler function of dialog "A". So, how can you programmatically launch a second dialog window after the user hits the "OK" button on the first ?
(I had tried to create an additional Listener for a field that is updated in dialog "A" to trigger dialog "B" but this doesn't work either.)
Thanks..
Check out the documentation: http://developer.yahoo.com/yui/container/dialog/#events. The following code should do the trick:
var firstDialog = new YAHOO.widget.Dialog('firstDialog', { postmethod: "manual" });
firstDialog.manualSubmitEvent.subscribe(function (type, args) {
var nextDialog = new YAHOO.widget.Dialog('nextDialog', { });
/* more configuration stuff... */
nextDialog.render();
nextDialog.show();
});
firstDialog.render();
firstDialog.show();
This handles when the form is to be submitted, which I think what you mean by selects a value, but if not let me know and I can give some help on that situation.

Resources