Opened 9 years ago
Closed 6 years ago
#15644 closed feature (fixed)
simpler API for registering robot actions and user callbacks
Reported by: | bill | Owned by: | bill |
---|---|---|---|
Priority: | undecided | Milestone: | 2.0 |
Component: | TestFramework | Version: | 1.7.3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
For 2.0 I'd like to have a cleaner API for writing robot tests. I'm imagining something like this:
runTest: function(){ return robot.sequence( robot.mouseMoveAt("myButton1"), robot.mouseClick(), 500, // wait 500ms function(){ doh.t(...); } robot.mouseMoveAt("myButton2"), robot.mouseClick(), 500, // wait 500ms function(){ doh.t(...); } ); }
sequence() would return a Deferred (seqPromise).
That would both simplify the robot code, and simplify users' lives by not having to do
var d = new doh.Deferred(); ... d.getTestErrback(...) ... d.getTestCallback()
See also #15642.
Change History (3)
comment:1 Changed 9 years ago by
comment:2 Changed 8 years ago by
Milestone: | tbd → 2.0 |
---|---|
Owner: | set to bill |
Status: | new → assigned |
I might still do this, especially since I've already got the basis for it in the seqPromise code I added in [29098]. On the other hand maybe a abbreviated promise interface like in Colin's teststack code is better, something like:
runTest: function(){ return robot.chain(). mouseMoveAt("myButton1"). mouseClick(). wait(500). then(function(){ doh.t(...); }). mouseMoveAt("myButton2"). mouseClick(). wait(500). then(function(){ doh.t(...); }); }
That's more concise than my original idea (and more concise than the current API), and moves towards being able to use teststack eventually.
Robot.sequence as I wrote in the description could actually be implemented in a backwards-compatible way by looping over its arguments and chaining each one onto seqPromise... although it would be much cleaner for the test to return a Promise, rather than using the seqPromise global.
comment:3 Changed 6 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
This is solved with Intern, http://theintern.io/
Unsurprisingly, I'm not the first one to have thought of this. See http://code.google.com/p/selenium/wiki/WebDriverJs#Managing_an_Asynchronous_API.