browser.actions().click() does not work with async/await
See original GitHub issueHi, I am converting my protractor tests from Promises to async/await and I found something weird with browser actions click. The problem is that the click() does not execute, but the mouseMove does. The click() works when test is written as a promise not async/await
Here is the test and the browser.actions function
it('When entering selection state selection toolbar should appear', async () => {
const page = new SingleObjectPage();
await page.get('barchart', 'PWFwr', 'select=clearall');
await page.activateSelectionMode($(barlayer));
await browser.wait(EC.visibilityOf($(SingleObjectPage.selectors.object.confirmButton)), timeout, 'Confirm button did not appear');
});
activateSelectionMode(element) {
return browser.actions()
.mouseMove(element, {
x: 20,
y: 75,
})
.click()
.perform();
}
I found a workaround to get it to work.
activateSelectionMode(element) {
return browser.actions()
.mouseMove(element, {
x: 20,
y: 75,
})
.perform().then(() => browser.actions()
.click()
.perform());
}
Bug report
- Node Version:
9.0.0
- Protractor Version:
5.1.1
- Angular Version:
1.5.8
- Browser(s):
chrome
- Operating System and Version
Selenium-docker
https://github.com/SeleniumHQ/docker-selenium
Issue Analytics
- State:
- Created 6 years ago
- Reactions:14
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Protractor browser.actions().dragandDrop async await not ...
I have found this solution to work. I am going to implement it into a helper function moving forward. await browser.actions().
Read more >Use Promise.all to Stop Async/Await from Blocking Execution ...
To see these in action, open up developer tools ( command + option + I ), copy paste the code sample into the...
Read more >for await...of - JavaScript - MDN Web Docs
The for await...of statement creates a loop iterating over async iterable objects as well as sync iterables. This statement can only be used ......
Read more >How JavaScript works: Event loop and the rise of Async ...
This means that the browser can't render, it can't run any other code, it's just stuck. And here comes the problem — your...
Read more >angular/protractor - Gitter
Only problem I have found is that browser.pause etc. stops working if you do. ... mouseMove(element(by.id(passwordID))).click().perform(); }).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Note: I am using a wrapper class for
element
. Replacethis.webElement
with your element variable.This is how I am doing it with async and await:
I’m doing this in an ‘actions wrapper’:
Which is lame sauce because the docs for ActionSequence.click() say:
Trying to move away from control flow as that seems like the recommended approach, this is an obstacle to that.