How to parse the string content of debugDescription in XCUITest swift - swift

As debugDescription returns the XCUIElement UI Tree and this if of type String.
Want to fetch specific information based upon parameters like label :[String] will return all the label values, find_Application - will return the bundleID etc

You can use element.snapshot().dictionaryRepresentation which gives a parsed version of output of element.debugDescription or element.snapshotDescription.
You can use element.snapshot().children to get the child element's snapshots iteratively if you want to create your own parser.

Related

How to extract the value from a json object in Azure Data Factory

I have my ADF pipeline, Where my final output from set variable activity is something like this {name:test, value:1234},
The input coming to this variable is
{
"variableName": "test",
"value": "test:1234"
}
The expression provided in Set variable Item column is #item().ColumnName. And the ColumnName in my JSon file is something like this "ColumnName":"test:1234"
How can I change it so that I get only 1234. I am only interested in the value coming here.
It looks like you need to split the value by colon which you can do using Azure Data Factory (ADF) expressions and functions: the split function, which splits a string into an array and the last function to get the last item from the array. This works quite neatly in this case:
#last(split(variables('varWorking'), ':'))
Sample results:
Change the variable name to suit your case. You can also use string methods like lastIndexOf to locate the colon, and grab the rest of the string from there. A sample expression would be something like this:
#substring(variables('varWorking'),add(indexof(variables('varWorking'), ':'),1),4)
It's a bit more complicated but may work for you, depending on the requirement.
It seems like you are using it inside of an iterator since you got item but however, I tried with a simple json lookup value
#last(split(activity('Lookup').output.value[0].ColumnName,':'))

Swift string with key-value, is this format standard ? How can I get it as a dictionary?

I work with an array of string, each string var is a coded object.
I want to decode the object, when I print a string var I get something structured like that :
"firstName=\"Elliot\" lastName=\"Alderson\" gender=\"male\" age=\"33\",some description I also need to get"
Is that a standard format to store key value properties ? I can't find anything on internet. The keys are always the same so that's not a big deal to get theses values as a dictionary but I would like to know if there is like a best practice method to get theses data instead of just searching for each key and then reach value from the first quote to the second one (for each value)
Because my file is 30000 lines so I better choose the more optimized way.
Thanks !

dynamic destination on exit block

i need to forward an agent to a specific service depending on a cycle written in a database; in the model, i have written the following code:
serviceTo = selectFrom(ciclo)
.where(ciclo.sequenza.eq(agent.sequenza))
.where(ciclo.sku.eq(agent.SKU))
.uniqueResult(ciclo.service);
serviceTo.take(agent)
the problem is that: "serviceTo" is a string and the method take is not working with that. how can i use the "serviceTo" variable in order to deliver the agent to the right enter?
You will need to parse your value, eg. convert your string serviceTo, that you retrieve from the database to a Java/AnyLogic object of type Enter.
In order to do so, create a Collection allMyEntersCollecton of type Enter and add all your Enter-objects that you want to be able to parse. You can also do this by selecting all your Enter blocks, right click, and use create Collection.
Create a parsing function parseEnter that returns a result of type Others/Enter and takes an input parameter serviceTo of type String:
for(int i=0;i<allMyEntersCollection.size();i++){
if(allMyEntersCollection.get(i).getName().equalsIgnoreCase(serviceTo)){
return allMyEntersCollection.get(i);
}
}
//nothing found, will probably cause a NullPointerException later:
return null;
Now all you have to do is to run this function parseEnter with your parameters:
Enter serviceToObject = parseEnter(serviceTo);
Of course the parsing only works if the String really contains exactly the name of any of the Enter objects in your Collection.
Use the resulting Enter-object:
serviceToObject.take(myExampleAgent);

Fluid Query Result object to JSON

I have a result object in my view and want do put this in JSON format.
The Object looks like
TYPO3\CMS\Extbase\Persistence\Generic\QueryResultprototypeobject (32 items)
0 => KN\Operations\Domain\Model\Operationprototypepersistent entity (uid=853,
pid=90)
1 => KN\Operations\Domain\Model\Operationprototypepersistent entity (uid=852,
pid=90)
....
I tried to use format
{myObject-> f:format.json()}
but this doesn't work. Result is
{}
I want to give that informations to my JS. For me it is not possible to change the Controller because I don't want to change an existing extension.
the format.json viewhelper expects an array as the value. To get the right result you need to convert your result into an array.
If you set the first param of the execute function in your repository to true you will get an array instead of an Queryresult Object.
return $query->execute(true);
You can find additional information on the documentation page of the viewhelper: https://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/ViewHelper/Format/Json.html
Happy Coding!

JQuery Wildcard for using atttributes in selectors

I've research this topic extensibly and I'm asking as a last resort before assuming that there is no wildcard for what I want to do.
I need to pull up all the text input elements from the document and add it to an array. However, I only want to add the input elements that have an id.
I know you can use the \S* wildcard when using an id selector such as $(#\S*), however I can't use this because I need to filter the results by text type only as well, so I searching by attribute.
I currently have this:
values_inputs = $("input[type='text'][id^='a']");
This works how I want it to but it brings back only the text input elements that start with an 'a'. I want to get all the text input elements with an 'id' of anything.
I can't use:
values_inputs = $("input[type='text'][id^='']"); //or
values_inputs = $("input[type='text'][id^='*']"); //or
values_inputs = $("input[type='text'][id^='\\S*']"); //or
values_inputs = $("input[type='text'][id^=\\S*]");
//I either get no values returned or a syntax error for these
I guess I'm just looking for the equivalent of * in SQL for JQuery attribute selectors.
Is there no such thing, or am I just approaching this problem the wrong way?
Actually, it's quite simple:
var values_inputs = $("input[type=text][id]");
Your logic is a bit ambiguous. I believe you don't want elements with any id, but rather elements where id does not equal an empty string. Use this.
values_inputs = $("input[type='text']")
.filter(function() {
return this.id != '';
});
Try changing your selector to:
$("input[type='text'][id]")
I figured out another way to use wild cards very simply. This helped me a lot so I thought I'd share it.
You can use attribute wildcards in the selectors in the following way to emulate the use of '*'. Let's say you have dynamically generated form in which elements are created with the same naming convention except for dynamically changing digits representing the index:
id='part_x_name' //where x represents a digit
If you want to retrieve only the text input ones that have certain parts of the id name and element type you can do the following:
var inputs = $("input[type='text'][id^='part_'][id$='_name']");
and voila, it will retrieve all the text input elements that have "part_" in the beginning of the id string and "_name" at the end of the string. If you have something like
id='part_x_name_y' // again x and y representing digits
you could do:
var inputs = $("input[type='text'][id^='part_'][id*='_name_']"); //the *= operator means that it will retrieve this part of the string from anywhere where it appears in the string.
Depending on what the names of other id's are it may start to get a little trickier if other element id's have similar naming conventions in your document. You may have to get a little more creative in specifying your wildcards. In most common cases this will be enough to get what you need.