IF condition is getting failed ..solution plz - if-statement

eval if (success == 'Data1') karate.call('test.feature')
this is getting failed displaying error message as
Expected ; but found { }
Tried below :
eval if (success == 'Data1') karate.call('test.feature');

Changing your step to below would work
* eval (success == 'Data1') ? karate.call('test.feature') : karate.call('fail.feature')

Related

Error while executing if else condition in Powershell

I am trying to execute the if & else code but unable to pass through the condition
{
if(($ENV_TYPE = 'Dev') && ($REGION_CODE = 'eus2'))
{
}
else
{
}
}
Both the env_type and region_code values are getting from env variables
I get this error:
The token '&&' is not a valid statement separator in this version.
if ($ENV_TYPE -eq 'Dev' -And $REGION_CODE -eq 'eus2'){
}

If statement not going to else statement in Katalon Studio for Android

I am using Katalon for Android Testing. I want it to click ImageView3 if it is present. If not, it will click ImageView2 (which makes ImageView3 appear later).
I have tried verifyElementVisible and verifyElementNotVisible. Also tried adding the if statement as 'if (Mobile.verifyElementVisible(findTestObject('Objects/android.widget.ImageView3'), 0) == true)' but this produced the same error.
Mobile.tap(findTestObject('Objects/android.widget.ImageView1'), 0)
if (Mobile.verifyElementVisible(findTestObject('Objects/android.widget.ImageView3'), 0))
{
Mobile.verifyElementVisible(findTestObject('Objects/android.widget.ImageView3'), 0)
Mobile.tap(findTestObject('Objects/android.widget.ImageView3'), 0)
Mobile.closeApplication()
} else
{
Mobile.tap(findTestObject('Objects/android.widget.ImageView2'), 30)
Mobile.verifyElementVisible(findTestObject('Objects/android.widget.ImageView3'), 0)
Mobile.tap(findTestObject('Objects/android.widget.ImageView3'), 0)
Mobile.closeApplication()
}
The error in the log is showing the following:
Reason: com.kms.katalon.core.exception.StepFailedException: Element 'Object Repository/Objects/android.widget.ImageView3' not found at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:48)
As ImageView3 was not found, I would expect it to jump to the else statement. Any suggestion why this is not happening?
The FailureHandling was not set. It would throw an error as this was not set.
Added FailureHandling.OPTIONAL to the if statement
if (Mobile.verifyElementVisible(findTestObject('Objects/android.widget.ImageView3'), 0, FailureHandling.OPTIONAL))

PHP with 'enexpected' T_ELSEIF

I am really wondering why this code is wrong, I have already been searching for a solution for over an hour on the internet! this is for a school project.
error:
Parse error: syntax error, unexpected 'elseif' (T_ELSEIF) in C:\00usbx\xampp\htdocs\index.php on line 344
script from line 344 to 346:
} elseif ($path[2] == 'noteshop') {
$post = $path[3]; {
if($_SESSION[login] == 'true') { ?>
you need to terminate the original if with an else :
} elseif ($path[2] == 'noteshop') {
$post = $path[3];
else {} // ?
if($_SESSION[login] == 'true') { ?>
i don't know your intent but there was an errant { which i couldnt understand as a nested expression or just cruft

How do I format the following if/else in Jasper?

I am trying to format the following if/else in Jasper and having trouble. This is what I have but my syntax is wrong can someone help?
$F{PAYMENT_METHOD_DATA} == {"deposit_name":"PayNearMe","is_important":true,"logo":"https:\/\/nj-cdn-casino.ballyinteractive.com\/cms\/V3\/Deposit-Methods\/icon-Paynearme.png"} ? "PayNearMe" :
$F{PAYMENT_METHOD_DATA} == {"deposit_name":"ACH (Optimal)","withdrawal_name":"ACH (Optimal)","display_order":"101","is_important":true} ? "ACH" :
$F{PAYMENT_METHOD_DATA} == {"deposit_name":"wire transfer","withdrawal_name":"wire transfer","display_order":"42","is_important":true} ? "Wire Transfer" :
$F{PAYMENT_METHOD_DATA} == {"deposit_name":"Personal check","withdrawal_name":"Personal check","display_order":"6","is_important":true} ? "Personal Check" :
$F{PAYMENT_METHOD_DATA} == {"deposit_name":"Cashier''s check","withdrawal_name":"Cashier''s check","display_order":"7","is_important":true} ? "Cashiers Check": "Cash"
Ternary operator should be like
condition ? execute true code : execute false code
jasper condition should be like,
$F{PAYMENT_METHOD_DATA} == "deposit_name"?"PayNearMe":"PayMe"
if you want to check multiple conditions, then you should write like,
$F{PAYMENT_METHOD_DATA} == "deposit_name"?($F{PAYMENT_METHOD_DATA} == "deposit_name_other"?"PayNearMeYes":"PayMeYes"):"PayMe"

Faulting application name issue with application

I have a code like shown below
if ((client == NULL) || (client->type == Leave_Agent)) {
but when i changed it with following code i am getting errors in event logs
the modified code is shown below
if (((client == NULL)|| (client->type == Leave_Agent)) && (client->type == 0)) {
errors in event log is
Faulting application name: test.exe, version: 8.0.16.0, time stamp: 0x5036427e
Can any body guide me how to fix this, which stopping my application.The && operator will make any issues in c++ ?
if (((agent == NULL)|| (agent->type == SPUES_ntAgent)) && (agent->type == 0))
If agent is NULL then the left side of && will always be true and agent->type will always be accessed. So a NULL agent ensures a NULL dereference.
You should change your code to ensure it only gets dereferenced if it's not NULL.
I think you wanted to move the () around so that you never dereference the pointer if it's NULL:
if ((agent == NULL)|| ((agent->type == SPUES_ntAgent) && (agent->type == 0))) {
The problem is that you can reach this
agent->type == 0
when agent==NULL.
I cannot comment on how to fix without knowing what behaviour you expect. At the very least you should make sure agent is not dereferenced if it is ==NULL.