Telefonica / toolium

Wrapper tool of Selenium and Appium libraries to test web and mobile applications in a single project
Apache License 2.0
113 stars 61 forks source link

NOV-244340: expression for selecting in an array for a context storage #388

Closed robertomier closed 3 months ago

robertomier commented 4 months ago

So far....

Expressions starting with CONTEXT let us select elements saved in context or context.storage like

[CONTEXT:a.b.c] returns the 'c' property of the 'b' property of the 'a' element in the context

recently, the index in arrays was added, so that

[CONTEXT:a.1.b] returns the 'b' property of the element with index 1 in the 'a' array

Now... let's go a bit deeper and let's have a mechanism of selecting elements in an array of dictionaries by searching for an specific key, like this:

having this next structure saved in the context

   {
        "the_array": [
            {
                "id": "first-element",
                "text": "The value of the first element"
            },
            {
                "id": "second-element",
                "text": "The value of the second element"
            }
        ]
    }

we are now able to select like [CONTEXT:the_array.id=first-element.text] and the 'The value of the first element' will be returned

you can also use single or double quotes for the selection expression (id='first-element', "id"="first-element", etc..)

robertomier commented 4 months ago

Code Climate has analyzed commit 06d761e and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count Complexity 2 View more on Code Climate.

Sr codeclimate, puedo meter la función que indica como compleja con if elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif elif ... (que además puede llegar a evaluar por duplicado isinstance(value,list), que es mucho mejor, oiga)

image
codeclimate[bot] commented 4 months ago

Code Climate has analyzed commit 3ff199ac and detected 0 issues on this pull request.

View more on Code Climate.