Opened 7 years ago

Closed 4 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 7 years ago by bill

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.

comment:2 Changed 6 years ago by bill

Milestone: tbd2.0
Owner: set to bill
Status: newassigned

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 4 years ago by dylan

Resolution: fixed
Status: assignedclosed

This is solved with Intern, http://theintern.io/

Note: See TracTickets for help on using tickets.