Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing features, Flow Control and Store Variables #101

Closed
babuto00 opened this issue Feb 19, 2018 · 33 comments
Closed

Missing features, Flow Control and Store Variables #101

babuto00 opened this issue Feb 19, 2018 · 33 comments

Comments

@babuto00
Copy link

Hello, first of all, thank you for your wonderful work! However what I miss are functions I used from Flow Control and Store Variable plugins in former Selenium IDE in FF. Would it be possible to include such functions in the new version? Without any using any plugins, I believe a lot of users would appreciate it. Thank you!

@corevo
Copy link
Member

corevo commented Feb 19, 2018 via email

@corevo corevo changed the title Missing features Missing features, Flow Control and Store Variables Feb 20, 2018
@bryanl-csi
Copy link

@babuto00 do you have a link for "Flow Control"? I'm not familiar with that one.

@idefix1
Copy link

idefix1 commented Feb 21, 2018

I am not babuto00, but I guess he refers to this Firefox addon, which added flow control commands like gotoif, gotolabel and while to the old IDE.

There is also new Kantu IDE, and it already supports flow control in Chrome:
https://a9t9.com/kantu/docs/webextensions/selenium-ide#flowcontrol

@bryanl-csi
Copy link

Thanks!

Kind of surprised I never used that one.

@babuto00
Copy link
Author

Yeah, it's that firefox addon idefix1 linked. It was pretty useful. Sorry for late response

@setiseta
Copy link

are there also plans for the commands: for and forxml??

@corevo
Copy link
Member

corevo commented Feb 28, 2018

for will be added, along side while,
forXml is a bit problematic, because it can read your filesystem, which is a bit of a security risk.
We'll have to take a look on how we can do this, while keeping our security policy as permissive as possible.

@setiseta
Copy link

thanks, sounds good.
yes filesystem is a bit critical.
at the moment i don't use forxml, but for.

@corevo
Copy link
Member

corevo commented Apr 2, 2018

Just dropping an update on our current thoughts,
We're going to add the following commands:

  • if else end
  • while do end

We'll need to give for a bit more thought before we implement it (UI terms mostly).
UPDATE: We will add times which will cover most of for's use cases atm

We're looking for a way to migrate the unstructured old flow control. (e.g. goto gotoIf label etc...)

@Jongkeun
Copy link
Contributor

Do Store Variable controls include in #140 too?
For example, getEval, storeEval etc..

@corevo
Copy link
Member

corevo commented Apr 17, 2018

eval is a bit of a problem, but if also evals the target.
It's a problem we'll have to address, I don't know how, and I'm not sure whats gonna be the scope of the eval.
If we want a safer eval, we'll have to eval in an isolated environment, which means that storeEval and the likes are useless, since there is no access to the DOM.
But it might be enough for ifs.

@Jongkeun
Copy link
Contributor

Why do you think eval's scope has a problem?
About security?

@corevo
Copy link
Member

corevo commented Apr 26, 2018

Yes, say we let you eval in the extensions scope, you can get the entire DOM as text.
And if we let you eval in the content side of things, you can add a keylogger to the tab.
The problem is that the only thing that stops a user from evaling something dangerous, is his responsibility to check what it does.
There are a lot of blogs that tell you, add this core extension to your IDE and it'll do magic for you, these kind of features are things that vendors (specifically Mozilla), won't stand for.
We have already been asked to remove all usage of eval in the extension.

@babuto00
Copy link
Author

babuto00 commented May 2, 2018

Hello, just checking in to see if there is any progress relating to the flow control (while command etc.)?
Thank you!

@corevo
Copy link
Member

corevo commented May 2, 2018

Not at the moment, its best to follow the pr.
The work is spread across 3 big features we want to ship very soon, control flow, running projects from cli and plugins for the IDE.

@hohnan
Copy link

hohnan commented Aug 13, 2018

I have been trying out the new execute script functionality as well as an if statement but can't get the if statement to work with a variable.

In the scenario below, "site" is schoolsdev.

Am I not using the if statement correct as it always goes to the else statement unless I use a schoolsdev in the if statement.

execute script | return window.document.domain | host
execute script | return "${host}".slice(0, 10) | site
if | "${site}"=="schoolsdev"

@tourdedave
Copy link

@hohnan: I pushed a fix for this in d933324. It will go out in a release later today.

@hohnan
Copy link

hohnan commented Aug 15, 2018

@tourdedave: So far so good. Thanks for the quick turn around on that one!!!!

@tourdedave
Copy link

You're welcome!

@corevo
Copy link
Member

corevo commented Aug 21, 2018

Can we close this, now that we have control flow and executeScript?

@babuto00
Copy link
Author

yes

@corevo corevo closed this as completed Aug 27, 2018
@hvlucas
Copy link

hvlucas commented Aug 28, 2018

I'm still not able to do if statements on the IDE
if | ${storedAttribute}=="string"
Outputs:
Failed: Incomplete block at if

@cinnest
Copy link

cinnest commented Aug 28, 2018

@hvlucas, I had such an error when trying to run the if command alone. As far as I understood, it needs the end statement to close the block. So the command can not be run alone but in the test case with the end statement properly set. I hope it helps ;)

@hvlucas
Copy link

hvlucas commented Aug 28, 2018

@cinnest I have an end after my assertion statements, between the if statement. Can you show me a working example?

@cinnest
Copy link

cinnest commented Aug 28, 2018

@hvlucas, unfortunately I have no access to my computer right now. Tomorrow morning as soon as I get in the office I'll post it for you, ok? Sorry

@cinnest
Copy link

cinnest commented Aug 29, 2018

So @hvlucas here is a code that is working for me. It contains the if and while statement for looking for a string in a table. If this string is not on the first page of this table it will search on other pages 'til the next button is disabled or the string is found then it fails or passes the test.

{
      "id": "d4236f2b-4561-44ac-ade4-226fddd23576",
      "comment": "",
      "command": "if",
      "target": "${myStringExists} == 0",
      "targets": [],
      "value": ""
    }, {
      "id": "54ff14e1-2cab-42e3-848f-18e5c4b1fdab",
      "comment": "",
      "command": "storeXpathCount",
      "target": "xpath=(//table[contains(.,${myString})])",
      "targets": [],
      "value": "myStringExists"
    }, {
      "id": "23c522a2-1515-488c-2fcc-240314564e72",
      "comment": "",
      "command": "storeXpathCount",
      "target": "xpath=(//a[contains(@class, 'ui-paginator-next') and not(contains(@class, 'ui-state-disabled'))])",
      "targets": [],
      "value": "nextExists"
    }, {
      "id": "ff328784-dcfa-4ec2-ae28-3f4dd6eaf2be",
      "comment": "",
      "command": "while",
      "target": "${myStringExists} == 0 && ${nextExists} != 0",
      "targets": [],
      "value": ""
    }, {
      "id": "72157022-13a1-4c55-5167-d8f0a47b75ca",
      "comment": "",
      "command": "click",
      "target": "xpath=(//a[contains(@class, 'ui-paginator-next')])",
      "targets": [],
      "value": ""
    }, {
      "id": "72bb21b6-d45d-4097-b88a-a7024ee6717c",
      "comment": "",
      "command": "storeXpathCount",
      "target": "xpath=(//a[contains(@class, 'ui-paginator-next') and not(contains(@class, 'ui-state-disabled'))])",
      "targets": [],
      "value": "nextExists"
    },  {
      "id": "55accdce-68fe-4eb2-8a1b-bd6adb45bfd6",
      "comment": "",
      "command": "storeXpathCount",
      "target": "xpath=(//table[contains(.,${myString})])",
      "targets": [],
      "value": "myStringExists"
    }, {
      "id": "4467e1d1-2fcc-4e43-48d7-d0e10b3f5331",
      "comment": "",
      "command": "end",
      "target": "",
      "targets": [],
      "value": ""
    }, {
      "id": "9ea2b38d-4ea6-4fdd-8869-a4389490d025",
      "comment": "",
      "command": "else",
      "target": "",
      "targets": [],
      "value": ""
    }, {
      "id": "90ab24b6-959a-4a98-9ef1-652bfd01c64b",
      "comment": "",
      "command": "verifyElementPresent",
      "target": "xpath=(//table[contains(.,${myString})])",
      "targets": [],
      "value": ""
    }, {
      "id": "e69f0692-8f8e-4f0c-a813-281f854611fc",
      "comment": "",
      "command": "end",
      "target": "",
      "targets": [],
      "value": ""
    }

the test output when the if statement is false:

13.if on ${myStringExists} == 0... OK
20.else on ... OK
21.verifyElementPresent on xpath=(//table[contains(.,${myString})])... OK
22.end on ... OK

... and when it's true:

13.if on ${myStringExists} == 0... OK
14.storeXpathCount on xpath=(//table[contains(.,${myString})]) with value myStringExists... OK
15.storeXpathCount on xpath=(//a[contains(@Class, 'ui-paginator-next') and not(contains(@Class, 'ui-state-disabled'))]) with value nextExists... OK
16.while on ${myStringExists} == 0 && ${nextExists} != 0... OK
17.click on xpath=(//a[contains(@Class, 'ui-paginator-next')])... OK
18.storeXpathCount on xpath=(//a[contains(@Class, 'ui-paginator-next') and not(contains(@Class, 'ui-state-disabled'))]) with value nextExists... OK
19.end on ... OK
20.else on ... OK
21.verifyElementPresent on xpath=(//table[contains(.,${myString})])... OK
22.end on ... OK

Selenium IDE 3.2.5
Google Chrome Version 68.0.3440.106

@hvlucas
Copy link

hvlucas commented Aug 29, 2018

@cinnest Ok I figured it out, and now I feel super stupid.
I was trying to run my test FROM the if statement, so since it's trying to execute only that line then it failed (I'm guessing it doesn't consider the end).
Running the whole test works normally. I changed my original statement to "${storedVariable}"=="disabled", because it was considering the value of storedVariable as a variable itself.

@corevo
Copy link
Member

corevo commented Aug 29, 2018

It is a bug that you have to do that, our initial plan was to do ${storedVariable}=="disabled".
We are working on a fix.

@hvlucas
Copy link

hvlucas commented Aug 29, 2018

@corevo I see. How about running a test from the if statement not working? Is that intentional?

@corevo
Copy link
Member

corevo commented Aug 29, 2018

The first command is an if?

@hvlucas
Copy link

hvlucas commented Aug 29, 2018

Running from if statement (I've also tried to store the variable before hand, i'm just making a point with the screenshot):
screenshot from 2018-08-29 10-17-08
Running whole test:
screenshot from 2018-08-29 10-18-07

@tourdedave
Copy link

tourdedave commented Aug 29, 2018

Executing a control flow command by itself won't work since it will fail syntax validation. Using "Start from here" to set the if command as the starting point should work fine.

@hvlucas
Copy link

hvlucas commented Aug 29, 2018

@tourdedave Gotcha 👍 Thank you

@lock lock bot locked and limited conversation to collaborators Aug 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants