Reputation: 1418
When I am running the below code, I observed that the last 3 lines with 'var robot' are executed at the beginning itself and not after clicking on the textArea. How can I control the sequence of code execution?
var robot = require("robotjs");
it('Testing robotjs', function () {
browser.driver.get(www.abc.com");
element(by.xpath(button1)).click();
element(by.xpath(textArea)).click();
robot.typeString("hello world");
robot.moveMouse("605", "429");
robot.mouseClick("left");
});
Upvotes: 2
Views: 240
Reputation: 473823
This is the Protractor's Control Flow in action, put the last 3 lines into the last click's promise resolution function:
var robot = require("robotjs");
it('Testing robotjs', function () {
browser.driver.get("www.abc.com");
element(by.xpath(button1)).click();
element(by.xpath(textArea)).click().then(function () {
robot.typeString("hello world");
robot.moveMouse("605", "429");
robot.mouseClick("left");
});
});
Upvotes: 3