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

WIP Control Flow v2 #280

Merged
merged 144 commits into from Aug 12, 2018
Merged
Show file tree
Hide file tree
Changes from 143 commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
31c56ac
Tests and code (embedded in the test file) for control flow validation.
Jun 27, 2018
b4c7049
Fix for if/else leveling. Broke things into preprocess (leveling and …
Jun 28, 2018
46a2a69
WIP on cleaning up code into a more OO design.
Jun 28, 2018
95967b1
Refactored control flow preprocessing.
Jul 1, 2018
4af827d
Added do/while and do/repeatif support. Some additional cleanup as well.
Jul 1, 2018
9fc1515
WIP on linked list object creation.
Jul 3, 2018
3011873
Additional bits for linked list creation, and cleaned up the hard
Jul 3, 2018
2cc556c
Merge branch 'callstack' of github.com:SeleniumHQ/selenium-ide into c…
Jul 3, 2018
355e05e
Made it so #preprocess and #process return their respective collectio…
Jul 3, 2018
8b1b270
Renamed _processStack to stack. Also cleaned up #process to clone _pr…
Jul 3, 2018
7e342fa
Cleaned up CommandStackHandler to use better variable and method naming.
Jul 3, 2018
b9f0c8c
Moved setting the command and index on the CommandStackHandler into #…
Jul 3, 2018
f06031a
Renamed #confirm to #confirmControlFlowSyntax
Jul 3, 2018
378ea18
Moved away from the Command class hierarchy and towards a distilled s…
Jul 4, 2018
81ca69d
Renamed methods and variables in ControlFlowHandler to better denote …
Jul 5, 2018
099cf1c
Broke playback tree classes into individual files
Jul 5, 2018
2268a4b
Deleted previous attempt at control flow validation
Jul 5, 2018
b1a621a
Reordered commands within #mutation1
Jul 5, 2018
56315bf
Moved PlaybacTree.spec.js into a playback-tree directory to match the…
Jul 5, 2018
13ac6c1
Fixed import statement
Jul 5, 2018
d820ffd
Made it to so CommandStackHandler can loop through and preprocess the…
Jul 5, 2018
1e0042a
Reduced CommandStackHandler and PlaybackTree into just PlaybackTree. …
Jul 5, 2018
fa6810e
Moved command node processing over to a switch statement that leverag…
Jul 6, 2018
1f17a29
Added a dedicated test for checking that command nodes have the corre…
Jul 6, 2018
4c53829
Renamed #_processCommands to #_processCommandNodes
Jul 6, 2018
e646ffa
Created a playback directory and moved playback-tree.js there.
Jul 8, 2018
46030ef
Switched from strings to constants when referencing a command name.
Jul 8, 2018
bf2866d
Switched to testing with Command objects and updated the playback tre…
Jul 8, 2018
725f7a7
Renamed playback-tree.js to index.js and moved the CommandNode class …
Jul 8, 2018
9e56ada
Fixed do/repeatIf and while in the syntax tree
Jul 8, 2018
941caeb
Moved syntax validation into more succinct functions outside of Playb…
Jul 8, 2018
1ecbab8
Removed pre-emptive export
Jul 8, 2018
92de2a9
Reworked playback-tree into just functions and added coverage for som…
Jul 9, 2018
548fccf
Reordered functions to be alphabetical by object key
Jul 9, 2018
d611c31
Broke repeated procedures out into their own unique functions. Also e…
Jul 9, 2018
2c8dd81
Merge branch 'callstack' of github.com:SeleniumHQ/selenium-ide into c…
Jul 9, 2018
ca82fe6
Reduced syntax verification, leveling, and node connecting further. A…
Jul 10, 2018
37de4e0
Merge branch 'callstack' of github.com:SeleniumHQ/selenium-ide into c…
Jul 10, 2018
2b19664
Added commands to the CommandList along with their names, description…
Jul 10, 2018
389f9a8
Added no-op emitters for control flow commands to suffice test errors.
Jul 10, 2018
1fcaf02
Moved PlaybackTree to its own file.
Jul 10, 2018
8871df9
Dropped the 'ControlFlow' prefix from the command names and alphabeti…
Jul 10, 2018
306df64
Abstracted the command equality check into its own function
Jul 11, 2018
21ab5be
Changed syntax validation to throw SyntaxError
Jul 11, 2018
dba1bef
Made the leveling functions pure.
Jul 11, 2018
b84528c
Pulled the push down automata (a.k.a. the state array) into its own c…
Jul 11, 2018
2b7053d
Added #empty to state
Jul 11, 2018
aa270e8
Cleaned up the code around verifying else and else if syntax.
Jul 11, 2018
207c291
Broke syntax validaiton and command leveling into separate files and …
Jul 11, 2018
6a09008
Added correct file extension to test file and added another test case…
Jul 11, 2018
cda8742
Added correct file extension to test file and added another test case…
Jul 11, 2018
c5f962f
Wired up control flow syntax validation and command indentation. To h…
Jul 11, 2018
ad70d9b
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Jul 11, 2018
2edeef5
Merge branch 'control-flow-v2' of github.com:SeleniumHQ/selenium-ide …
Jul 11, 2018
7766e36
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Jul 12, 2018
9877023
Adjust linked list generation for control flow to skip over terminal …
Jul 17, 2018
c44d833
Cleaned up end, else, and do command node linking a bit further.
Jul 17, 2018
4870332
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Jul 17, 2018
5a89c8d
Fixed malformed copyright header
Jul 17, 2018
29a54e6
Added test to check end skip recursion.
Jul 17, 2018
ff55c78
A rough first pass on getting playback wired up with playback-tree.
Jul 17, 2018
4b70d8b
Added execution for control flow commands to playback. Pulled the set…
Jul 18, 2018
005b1e7
Fixed linter warnings
Jul 18, 2018
972c3b5
Wired up eval for expressions. Made a helper command for evaluateCond…
Jul 18, 2018
d2e5af6
Rolled the isExtCommand function into the class method of the same na…
Jul 18, 2018
d6213c4
Moved isWindowMethodCommand into extCommand and updated where it's us…
Jul 18, 2018
da8c771
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Jul 18, 2018
d7c4d3f
Fixed a bug introduced by commandLevels when deleting tests and test …
Jul 22, 2018
c78f561
Added a suite and tests for control flow commands.
Jul 22, 2018
04c632d
Added breaking on a potential infinite loop with optional override. A…
Jul 22, 2018
3d4df75
Made it so executing individual control flow commands throws a helpfu…
Jul 22, 2018
72c4297
Modified error copy
Jul 22, 2018
e39d4e6
Wired up errors from 1) hitting the max retry and 2) not providing a …
Jul 22, 2018
207d797
Fixed an edge case bug where an empty conditional branch (e.g., while…
Jul 22, 2018
141456c
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Jul 22, 2018
26ee833
Renamed `elseIf` to `else if` in models/Command.js, added 'else if' t…
Jul 23, 2018
a46cedc
First pass on sandbox eval (Chrome only).
Jul 24, 2018
7d2b9d6
Inlined conditional.
Jul 24, 2018
a59c315
Fixed a bug that prevented `do` from being used as the first command …
Jul 24, 2018
5abde35
Added standard HTML tags
Jul 24, 2018
c32d0f7
Moved iframe loading to bottom of body.
Jul 24, 2018
ff22cc7
Added error reporting for sandbox eval on Firefox. Also added resetti…
Jul 24, 2018
c30dbfe
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Jul 25, 2018
5f66294
Swapped copyright header
Jul 25, 2018
d0a73a5
Swapped the switch/case in `stringToBool` for a one-liner and swapped
Jul 25, 2018
41ad7c9
Made value explicit
Jul 25, 2018
d7e5cc5
Moved the eval return into its own variable
Jul 25, 2018
9e44774
Moved fetching the iframe into #eval and wrapped the `postMessage` in…
Jul 25, 2018
de7a9a7
Added a function to check if the open command is valid (e.g., name is…
Jul 25, 2018
138b430
Added conditional rendering of the sandbox so it doesn't happen on Fi…
Jul 25, 2018
942d2de
Removed hard-coded iframe declaration
Jul 25, 2018
7dd3de3
Updated `isLoop` to include `repeatIf`. Also updated `isControlFlow` …
Jul 25, 2018
b493b50
Added a function to increase `timesVisited` only if it is a loop and …
Jul 25, 2018
0f316fd
Refactored CommandNode
Jul 26, 2018
cb8903b
Added an `isTimes` lookup and updated `CommandNode#evaluate` with it.
Jul 26, 2018
2adad6c
Set playback state for successful control flow command execution
Jul 26, 2018
46b8148
Inlined conditional incrementing of `timesVisited` since it's only ne…
Jul 26, 2018
df0574a
Added a `return` on `reportError` when a control flow command isn't s…
Jul 26, 2018
7af5d1d
Created/moved test files into `playback-tree` directory to mirror wha…
Jul 26, 2018
f79682b
Added additional test coverage for CommandNode
Jul 26, 2018
e6861da
Refactored for testability, added test coverage, and made it so check…
Jul 26, 2018
ccb1007
Swapped hard-coded control flow command names for calls to `ControlFl…
Jul 26, 2018
73de6e4
Added characterization tests for when the sandbox resolves with a kno…
Jul 26, 2018
5609b03
Added a suite for all seed tests to make it a little easier to run th…
Jul 26, 2018
281df69
Changed the seed so it loads the 'Test suites' view with the first te…
Jul 26, 2018
f4001a8
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Jul 29, 2018
a88b2e2
Added execute script tests to the seed set and made them load in focu…
Jul 29, 2018
28148a9
Updated `doSeleniumCommand`'s call to `execute` on the commandNode to…
Jul 29, 2018
32d31c1
Renamed `Sandbox#eval` to `Sandbox#sendMessage` to mirror the `extCom…
Jul 29, 2018
fa6ebc5
First pass on code emitting for control flow commands.
Jul 30, 2018
b6473ea
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Jul 30, 2018
929f4b7
Defaulting seed.js to load the control flow if test for simplicity.
Jul 30, 2018
3890bac
Moved away from sanbox eval in favor of loading up bootstrap.html wit…
Jul 30, 2018
ce8a973
Removed console output from debugging
Jul 31, 2018
4ea0a77
Removed the `evalInContentWindow` parameter and commented out code fr…
Jul 31, 2018
77169c5
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Jul 31, 2018
ac8de08
Fixed linter errors
Jul 31, 2018
2245931
Removed the sandbox
Jul 31, 2018
476fbc4
Removed dynamic appending of the sandbox iframe
Jul 31, 2018
42492ea
Added 'assert' command
Jul 31, 2018
ede1097
Fixed line wrap on new reference text to be consistent
Aug 1, 2018
2f8ca5d
Updated CommandNode to support soft assertions (e.g., 'verify' comman…
Aug 1, 2018
cd7b06b
Moved the call for `doType` out of `doSeleniumCommand` and into `Comm…
Aug 1, 2018
438d65a
Swapped `ControlFlowCommandNames` to use the Command key instead of name
Aug 1, 2018
a5c956e
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Aug 1, 2018
7da80bd
Fixed the seed to use the correct command incantation (e.g., by key i…
Aug 1, 2018
ba30b42
Removed unnused import
Aug 1, 2018
ee61a37
Fix for a bug in `executeScript` and `executeAsyncScript` where the r…
Aug 1, 2018
fd461e9
Updated `doDelay` to reference the current command node to see if it'…
Aug 1, 2018
b0b92ba
Added plugin support to command nodes
Aug 5, 2018
9103185
Removed unnused import
Aug 5, 2018
7ce31ce
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Aug 5, 2018
2e40b4d
Removed open commands from control flow tests. Removed unnecessary ex…
Aug 6, 2018
0f16bc9
Removed the check for a valid open and storing this information in Pl…
Aug 6, 2018
edcb1cd
Fixed the result return for the command node on plugin commands so it…
Aug 6, 2018
7413bf6
Moved away from a `PlaybackTree` class instance in favor of returning…
Aug 6, 2018
9b11659
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Aug 6, 2018
dc57053
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Aug 9, 2018
e2d4f16
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Aug 9, 2018
8bae621
Merge branch 'master' of github.com:SeleniumHQ/selenium-ide into cont…
Aug 12, 2018
a3bae98
Pulled the call to set the `currentExecutingCommandNode` up from `doS…
Aug 12, 2018
1b5778a
Made the if seed test the default one loaded in the seed
Aug 12, 2018
fcdfedb
Removed reference to htmlutils.js and updated the sha digest in the m…
Aug 12, 2018
df3eb14
Made scoped explicit in `evaluateConditional`. Removed an unnecessary…
Aug 12, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/selenium-ide/src/content/bootstrap.html
Expand Up @@ -21,4 +21,25 @@
<body>
<h1>Preparing to run your test</h1>
</body>
<script>
var scripts = [
"assets/vendor/global.js",
"assets/vendor/selenium-browserdetect.js",
"assets/polyfills.js",
"assets/escape.js",
"assets/injector.js",
"assets/record.js"
];
var urls;
if (chrome) {
urls = scripts.map(script => (chrome.runtime.getURL(script)));
} else if (browser) {
urls = scripts.map(script => (browser.runtime.getURL(script)));
}
urls.forEach(url => {
var e = document.createElement("script");
e.src = url;
document.body.appendChild(e);
});
</script>
</html>
21 changes: 14 additions & 7 deletions packages/selenium-ide/src/content/commands-api.js
Expand Up @@ -42,32 +42,39 @@ function doCommands(request, sender, sendResponse) {
} else if (request.commands == "domWait") {
selenium["doDomWait"]("", selenium.preprocessParameter(""));
sendResponse({ dom_time: window.sideex_new_page });
} else if (request.commands === "evaluateConditional") {
try {
let value = selenium["doEvaluateConditional"](request.target);
sendResponse({ result: "success", value: value });
} catch(e) {
sendResponse({ result: e.message });
}
} else {
const upperCase = request.commands.charAt(0).toUpperCase() + request.commands.slice(1);
if (selenium["do" + upperCase] != null) {
try {
document.body.setAttribute("SideeXPlayingFlag", true);
let returnValue = selenium["do"+upperCase](selenium.preprocessParameter(request.target),selenium.preprocessParameter(request.value));
let returnValue = selenium["do" + upperCase](selenium.preprocessParameter(request.target), selenium.preprocessParameter(request.value));
if (returnValue instanceof Promise) {
// The command is a asynchronous function
returnValue.then(function() {
// Asynchronous command completed successfully
document.body.removeAttribute("SideeXPlayingFlag");
sendResponse({result: "success"});
sendResponse({ result: "success" });
}).catch(function(reason) {
// Asynchronous command failed
document.body.removeAttribute("SideeXPlayingFlag");
sendResponse({result: reason});
sendResponse({ result: reason });
});
} else {
// Synchronous command completed successfully
document.body.removeAttribute("SideeXPlayingFlag");
sendResponse({result: "success"});
sendResponse({ result: "success" });
}
} catch(e) {
// Synchronous command failed
document.body.removeAttribute("SideeXPlayingFlag");
sendResponse({result: e.message});
sendResponse({ result: e.message });
}
} else {
sendResponse({ result: "Unknown command: " + request.commands });
Expand All @@ -84,9 +91,9 @@ function doCommands(request, sender, sendResponse) {
try {
const element = selenium.browserbot.findElement(request.locator);
const locator = locatorBuilders.buildAll(element).find(([loc, strat]) => (/^xpath/.test(strat)))[0]; //eslint-disable-line no-unused-vars
sendResponse({result: "success", locator});
sendResponse({ result: "success", locator });
} catch(e) {
sendResponse({result: e.message});
sendResponse({ result: e.message });
}
}
if (request.selectMode) {
Expand Down
22 changes: 20 additions & 2 deletions packages/selenium-ide/src/content/selenium-api.js
Expand Up @@ -228,8 +228,16 @@ Selenium.prototype.reset = function() {
this.browserbot.resetPopups();
};

Selenium.prototype.eval = function(script, scoped = true) {
return window.eval(scoped ? `(() => {${script}})()` : script);
Selenium.prototype.eval = function(script, scoped = true, isExpression = false) {
if (isExpression) {
return window.eval(scoped ? `(() => (${script}))()` : script);
} else {
return window.eval(scoped ? `(() => {${script}})()` : script);
}
};

Selenium.prototype.doEvaluateConditional = function(condition) {
return !!(this.eval(condition, undefined, true));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not scoped?
In WebDriver it'll be scoped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make it explicit, but isn't it already scoped if it's undefined?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot it has a default value true, make it true anyway for clarification that it is required.
I put the default one, so that if it gets called from something internal that I'm not aware of, that it'll be scoped by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.

};

Selenium.prototype.doVerifyChecked = function(locator) {
Expand Down Expand Up @@ -331,6 +339,16 @@ Selenium.prototype.doVerifyElementNotPresent = function(locator) {
}
};

Selenium.prototype.doVerify = function(actual, expected) {
this.doAssert(actual, expected);
};

Selenium.prototype.doAssert = function(actual, expected) {
if (actual !== expected) {
throw new Error("Actual value '" + actual + "' did not match '" + expected + "'");
}
};

Selenium.prototype.doAssertChecked = function(locator) {
let element = this.browserbot.findElement(locator);
if (element.type !== "checkbox" && element.type !== "radio") {
Expand Down
11 changes: 5 additions & 6 deletions packages/selenium-ide/src/manifest.json
Expand Up @@ -42,7 +42,7 @@
"assets/prompt.css",
"assets/bootstrap.html"
],
"content_security_policy": "script-src 'self'; object-src 'self'",
"content_security_policy": "script-src 'self' 'sha256-UUwVIygWwzdom+NTsGSMgQnlQ8Phnj5BIK5+S3HWX4Y=' 'unsafe-eval'; object-src 'self'",
"content_scripts": [
{
"matches": [
Expand All @@ -60,9 +60,8 @@
"all_frames": true
}
],
"background": {
"scripts": [
"assets/background.js"
]
"background":
{
"scripts": ["assets/background.js"]
}
}
}
91 changes: 0 additions & 91 deletions packages/selenium-ide/src/neo/IO/ControlFlowValidator.js

This file was deleted.

38 changes: 24 additions & 14 deletions packages/selenium-ide/src/neo/IO/SideeX/ext-command.js
Expand Up @@ -370,20 +370,30 @@ export default class ExtCommand {
let upperCase = command.charAt(0).toUpperCase() + command.slice(1);
return "do" + upperCase;
}
}

export function isExtCommand(command) {
switch(command) {
case "pause":
case "open":
case "selectFrame":
case "selectWindow":
case "run":
case "setSpeed":
case "store":
case "close":
return true;
default:
return false;
isExtCommand(command) {
switch(command) {
case "pause":
case "open":
case "selectFrame":
case "selectWindow":
case "run":
case "setSpeed":
case "store":
case "close":
return true;
default:
return false;
}
}

isWindowMethodCommand(command) {
return (command == "answerOnNextPrompt"
|| command == "chooseCancelOnNextPrompt"
|| command == "assertPrompt"
|| command == "chooseOkOnNextConfirmation"
|| command == "chooseCancelOnNextConfirmation"
|| command == "assertConfirmation"
|| command == "assertAlert");
}
}