Is it possible to specify some kind of "OR" (alternative) clause in Cucumber?
I.e. if I have two valid responses to some event I would like my test to pass if either of them happens.
Something like that:
"When I press a button"
"Then I should see the text 'Boo'"
"Or I should see the text 'Foo'"
My particular scenario is a login screen. When I try to log in with some random password, I should see an error message "invalid password" if the server is working or a message "network error" if it is not.
You can't really define OR functionality using the Gherkin but you can pass in a list and check that one of the values in the list matches what was returned.
Define list:
Then the greeting service response will contain one of the following messages
|Hello how are you doing?|
|Welcome to the front door!|
|How has your day been?|
|Come right on in!|
Check list:
#Then("the get messages service response will contain one of the following messages")
public void text_matching_one_of_the_following(List<String> greetingMessages){
boolean success = false;
for(String message : greetingMessages){
assertTrue(textMatchesResponse(message));
}
}
OR is not supported. You can use Given, When, Then, And and But. Please refer to http://docs.behat.org/en/v2.5/guides/1.gherkin.html
But perhaps you could make use of the But keyword to achieve what you are looking for.
Related
I'm trying to filter out my Azure Dead Letter Queue messages in order to find a specific element from the deadletterqueue.
I downloaded the tool from https://github.com/paolosalvatori/ServiceBusExplorer and make the connection between azure and the tool. I can see the Messages from my deadletterqueu here:
enter image description here
In the messages i have a json value with a partnerValue like this:
{
"requestId": "6B454A4E-F8CB-4801-8874-8E97B149640E",
"partnerValue": "114033",
"productName": "myProductName",
}
I try to use the filter like this:
enter image description here
I read the artcile from https://www.sharepointeurope.com/azure-service-bus-topic-filters/ and tried a lot of things that didnt work, i tried:
partnerValue like "517182"
partnerValue = "517182"
partnerValue like '517182'
partnerValue = '517182'
"partnerValue" like "517182"
But i dont work, i can't find the value (i'm sure that the value exist even if i do a basic exemple you productName" it dont work...)
Any idea ?
Below filter expression should return messages,
partnerValue = '517182'
Check whether you are able to get messages using filter condition for active messages.
Also check are you able to get messages using sys property.
If any of the mentioned scenarios does not work, suggest you to try with another version of service bus explorer.
Reference link1
Reference link2
I have an interface with a list of users and a possibility to add a new one. I want to assert that this user is new (i.e. its email is not already used). So I should check that we have no message pop-up.
checkMailIsNotUsed: () =>
Task.where('#actor checks mail present message is absent',
Ensure.that(UsersList.messageArea, not(isVisible()))),
However this message area could be visible but not with the error messsage I don't expect. So I am looking for, in case above ensure fails, a way to ensure that the text does not include 'already exists'.
Ensure.that(Text.of(UsersList.messageArea), includes('already exists'))),
However if the first 'ensure' is false, everything stops. There is no 'or' or equivalent at the Ensure level. I need to do the second Ensure if first one fails.
How could I do that ?
Thanks in advance.
I have an almost-default installation of Auditbeat on several of my hosts, that are also auditing changes of /etc, that forward log data to a Logstash instance elsewhere. I want to generate a message based on these logs, as by default Auditbeat does not fill the message field with value (they moved it to event.original and anyway it's disabled, and I want to be as close to production as possible with my configs), so that Kibana displays "failed to find message" when I try viewing logs from auditbeat-*. So I went to parsing and adding fields to events with Logstash.
I have encountered an interesting issue: If I query something that belongs to any custom tree under root in JSON but event, Logstash filters work, but should I decide to query [event][type], the result is always false. The problem is, if I just stuff "%{[event][type]}" into my message, the value is in there! I have tried if ([event][type] == "info") {...}, if ([type] == "info") and also tried if ([event][action] == "change") to no avail, while when I do output a debug message value with "%{[event][type]} %{[event][action]}" both values are present and equal to whatever I'm comparing to. Note that [event][module] filter actually works, so this behavior with [event][type] really baffles me.
So, how to filter based on [event][type] in Logstash, provided they are present in incoming data?
The answer was pretty simple. Both event.type and event.action are arrays and not strings, so comparing an array to a string returned false. The proper way of filtering through these is using "in", like this:
if "info" in [event][type] {...}
I've been trying to make a ship command that can either ship the author of the message with a mentioned user, or ship two mentioned users. I can get the 1st mention in a message but I have no idea on how to get the 2nd or even third mention in a message. I tried using:
message.mentions.users.first(2)
splitting the args then slicing them so only the second mention is avalaible, but this gives an "undefined" error when I try to get the username.
Could someone give me a script on exactly how to do it since I can't really get the hang of this
According to the documentation message.mentions.users yields a Collection. So you can just iterate over this collection or convert it to an array and then access the required index:
const userArray = message.mentions.users.array();
console.log(userArray[yourDesiredIndex]);
I'm now stuck on the problem of getting user input (what user says) in my index.js. For example, the user says: please tell me if {animals} can live between temperature {x} to {y}. I want to get exact value (in string) for what animals, x and y so that I can check if it is possible in my own server. I am wondering how to do that since the entities need to map to some exact key values if I annotate these three parameters to some entities category.
The methods for ApiAiApp is very limited: https://developers.google.com/actions/reference/nodejs/ApiAiApp
And from my perspective, none of the listed methods work in this case.
Please help!
Generally API.AI entities are for some set of known values, rather than listening for any value and validating in the webhook. First, I'd identify the kinds of entities you expect to validate against. For the temperatures (x and y), I'd use API.AI's system entities. Calling getArgument() for those parameters (as explained in the previous answer) should return the exact number value.
For the animals, I'd use API.AI's developer entities. You can upload them in the Entity console using JSON or CSV. You can enable API.AI's automated expansion to allow the user to speak animals which you don't support, and then getArgument() in webhook the webhook will return the new value recognized by API.AI. You can use this to validate and respond with an appropriate message. For each animal, you can also specify synonymous names and when any of these are spoken, and getArgument() will return the canonical entity value for that animal.
Extra tip, if you expect the user might speak more than one animal, make sure to check the Is List box in the parameter section of the API.AI intent.
If "animals", "x", and "y" are defined as parameters in your Intent in API.AI, then you can use the getArgument() method defined in ApiAiApp.
So the following should work:
function tempCheck( app ){
var animals = app.getArgument('animals');
var x = app.getArgument('x');
var y = app.getArgument('y');
// Check the range and then use something like app.tell() to give a response.
}