Im using Protractor with Cucumber and Im facing this issue.
And Right-Click on the first record Sort Pair #
RQA\node_modules\cucumber\src\support_code_library_builder\define_helpers.js:90
TimeoutError: Wait timed out after 8109ms
at C:\Users\VBG5LLN\Documents\Automation Files\Automation RQA\node_modules\selenium-webdriver\lib\promise.js:2201:17
at ManagedPromise.invokeCallback_ (C:\Users\VBG5LLN\Documents\Automation Files\Automation RQA\node_modules\selenium-webdriver\lib\promise.js:1376:14)
at TaskQueue.execute_ (C:\Users\VBG5LLN\Documents\Automation Files\Automation RQA\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\Users\VBG5LLN\Documents\Automation Files\Automation RQA\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at C:\Users\VBG5LLN\Documents\Automation Files\Automation RQA\node_modules\selenium-webdriver\lib\promise.js:2927:27
at C:\Users\VBG5LLN\Documents\Automation Files\Automation RQA\node_modules\selenium-webdriver\lib\promise.js:668:7
at processTicksAndRejections (internal/process/task_queues.js:97:5)
I already tried many changes but the error is present anyway.
I set 60000 in; allScriptsTimeout, getPageTimeout and defaultTimeoutInterval in conf.js
(And basically in every timeout flag I set an high number).
I delete all the steps in the function and the error is still present:
Then('Right-Click on the first record Sort Pair', async function (){
await browser.sleep(2000);
});
I fix the issue, in the previous step I clicked a button and wait for it with this;
await expect(browser.wait(EC.visibilityOf(ntwrkHomeObs.applyBtn), 8000));
await ntwrkHomeObs.applyBtn.click();
The button is visible since the page load and continues in the DOM after is clicked just hided inside a div that is visible again if clicks a "Show Options" button.
For some reason this causes the issue.
I deleted this line;
await expect(browser.wait(EC.visibilityOf(ntwrkHomeObs.applyBtn), 8000));
Related
i'm using puppeteer and i need to keep refreshing the page until the requested element is live, "button" is the element i need.
i tried with the wait until but it is not working and gives me this error:
Error: Unknown value for options.waitUntil: JSHandle#node
This is what i tried
const [button] = await page.$x("//a[contains(., 'Denim')]");
if (button) {
await button.click();
}
await page.reload({ waitUntil: ["networkidle0", "domcontentloaded", button] });
The error is pretty explicit in this case. You are telling puppeteer to wait for these 3 things: ["networkidle0", "domcontentloaded", button]. The first 2 are acceptable options. The 3rd is not. button is a reference to a DOM element which you can use in your puppeteer code. (Or a JSHandle#node). As per the docs, this is not a viable option.
Just another point here: you don't share all your code so we must assume that this is happening in some sort of loop with some sort of timeout between calls. As is, this code will check for this button, click the button if found, and then reload the page exactly 1 time. Reload does not reload the page multiple times while searching for some feedback. It just reloads once. The waitUntil option just defines when the returned promise should resolve.
Good luck!
I try to upload a file in ProTractor to the application, which is developed in Angular with Electron.
To do it manually I need to click on the "Browse" button and then select a file in the windows dialog "Open".
I managed already the part for providing of the path to the file and click on "Open" button on the dialog by using of AutoIt
var autoIt = require('autoit');
autoIt.Init();
autoIt.WinActivate("Open");
autoIt.WinWait("Open");
autoIt.ControlSetText("Open", "", "1148", appPath);
autoIt.ControlClick("Open", "", "1");
But this part of the code will be not executed after click on the "Browse" button
element(by.id('browseText')).click();
I guess that ProTractor waits for angular or for page loading, but because after clicking on the button the windows dialog is opened, the execution of further code is blocked. Also afterward I couldn't just output something in the console.
Is there an option to disable wait for page loading and to perform the action immediately after the click?
Unfortunately, the disabling of waiting for Angular didn't help as well as synchronization ignoring
browser.waitForAngularEnabled(false);
browser.ignoreSynchronization = true;
Thank you in advance for your support.
UPDATED
The problem is in the timing because when I try to execute the small following code
browser.waitForAngularEnabled(false);
element(by.id('browseText')).click()
.then(function () {
console.log("clicked");
});
browser.sleep(5000)
.then(function () {
console.log("5 sec are over!");
}); // wait 5 sec
browser.sleep(3000);
console.log("End");
The following happens:
Firstly the "End" will be added to the console without waiting for 3 seconds.
Afterward, the dialog will be opened, that means that the button was clicked
And at the end, the test will be failed with Error "function timed out, ensure the promise resolves within 90000 milliseconds".
Here is the output of this code:
[09:37:14] I/launcher - Running 1 instances of WebDriver
[09:37:14] I/direct - Using ChromeDriver directly...
..End
..F
Failures:
1) Scenario: Add an application # features\tst_General.feature:10
V Before # features\steps\DataGrid.js:20
V Before # features\steps\General.js:25
V When The "bounce" application has been added # features\steps\General.js:65
V After # features\steps\General.js:29
× After # node_modules\protractor-cucumber-framework\lib\resultsCapturer.js:2
5
Error: function timed out, ensure the promise resolves within 90000 milli
seconds
at Timeout._onTimeout (C:\Users\10050296\Documents\workspace\sm-protr
actor-automation\node_modules\cucumber\src\user_code_runner.js:61:18)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
1 scenario (1 failed)
1 step (1 passed)
1m30.217s
Let's be clear.
This is work 100%:
browser.waitForAngularEnabled(false);
Protractor part, as I understand, also work. The Browser button is clicked.
So, the issue in the Autoit part. The question is - "How to run Autoit?"
Just add sleep to check is it waiting problem on the Autoit side:
element(by.id('browseText')).click();
browser.sleep(5000); // wait 5 sec
...
autoit code
...
If it works, so the issue in Autoit waiting.
I have a case where I need to wait for the "Waiting for data to load" modal to disappear and said modal depends on $http request running.
I've used browser.wait statement, using Expected Conditions according to Protractor API.
My statement has currently this form:
beforeEach(function() {
browser.wait(element(EC.invisibilityOf(element(by.css(".msg-overlay"))), 30000);
});
it("describes something", function() {
...do some actions involving clicking...
})
Unfortunately spec always fails with message:
Message:
Failed: Timed out waiting for Protractor to synchronize with the page after 11 seconds. Please see https://github.com/angular/protractor/blob/master/docs/faq.md
While waiting for element with locator - Locator: By(css selector, .msg-overlay).
The following tasks were pending:
- $http:
Stack:
Error: Failed: Timed out waiting for Protractor to synchronize with the page after 11 seconds. Please see https://github.com/angular/protractor/blob/master/docs/faq.md
While waiting for element with locator - Locator: By(css selector, .msg-overlay).
The following tasks were pending:
- $http:
at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:101:16
at Promise.invokeCallback_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1329:14)
at TaskQueue.execute_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2790:14)
at TaskQueue.executeNext_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2773:21)
I don't want to set allScriptsTimeout to 30000, as this would slow down actual fails, I would just like Protractor to wait for one modal to disappear. Help?
I think you can temporarily change the allScriptsTimeout on the fly in as similar fashion as you would do with the jasmine default timeout interval (not tested):
var originalTimeout;
beforeEach(function() {
originalTimeout = browser.allScriptsTimeout;
browser.allScriptsTimeout = 35000;
browser.wait(element(EC.invisibilityOf(element(by.css(".msg-overlay"))), 30000);
});
afterEach(function() {
browser.allScriptsTimeout = originalTimeout;
});
I'm using angular-growl-v2 notifications in my app.
They work ok, the problem comes on my protractor tests. I have to use a TTL (around 6 seconds) as it is a requirement. Then I have the following test:
it('should send a request and notify the user about the result',function(){
detailPage.verifyEmailtButton.click().then(function(){
var expectedDiv = element(by.css('.alert-success'));
expect(expectedDiv).toBeDefined();
});
});
But it is always throwing an error:
NoSuchElementError: No element found using locator: By.cssSelector(".alert-success")
This does not happens when the TLL is -1.
Someone can help here? Thanks in advance.
angular-growl-2 uses $timeout, which doesn't play nicely with protractor: protractor waits for the timeout to end before it completes its sync with angular process.
So by the time it reaches your expect call, the timeout has elapsed and the alert is no longer there. Check out the Waiting for page synchronization section of this doc:
https://github.com/angular/protractor/blob/master/docs/timeouts.md
(This page relates to timeouts, which you don't appear to be experiencing, but since the default timeout is 11 seconds, it could well be that the entire process, including your 6 second TTL, takes place before a timeout happens)
There's a PR to angular-growl-v2 to use $interval instead of $timeout, but its currently waiting for tests:
https://github.com/JanStevens/angular-growl-2/pull/85
Explicitly wait for the alert to be present after clicking the button:
detailPage.verifyEmailtButton.click();
var EC = protractor.ExpectedConditions;
var expectedDiv = element(by.css('.alert-success'));
browser.wait(EC.presenceOf(expectedDiv), 10000, "No alert present");
using the element(by.model()) syntax to find a field and input text.
element(by.model('sample_ad.id')).sendKeys('batman');
gets the exception from chromedriver:
Stacktrace:
Error: Timed out waiting for Protractor to synchronize with the page after 11 seconds
at Error (<anonymous>)
==== async task ====
WebDriver.executeScript()
at Protractor.waitForAngular (/Users/jon/dev/project_name/node_modules/protractor/lib/protractor.js:278:22)
at Protractor.findElement (/Users/jon/dev/project_name/node_modules/protractor/lib/protractor.js:427:8)
at Object.elementFinder.(anonymous function) [as sendKeys] (/Users/jon/dev/project_name/node_modules/protractor/lib/protractor.js:62:21)
at null.<anonymous> (/Users/jon/dev/project_name/test/e2e/features/somedirectiveSpec.js:24:39)
at /Users/jon/dev/project_name/node_modules/protractor/jasminewd/index.js:54:12
==== async task ====
at null.<anonymous> (/Users/jon/dev/project_name/node_modules/protractor/jasminewd/index.js:53:12)
at null.<anonymous> (/Users/jon/dev/project_name/node_modules/protractor/node_modules/minijasminenode/lib/async-callback.js:45:37)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
Not sure why this is breaking, but Protractor seems very fragile right now... I have no issues using the browser object to find elements, input text, etc...
Any help would be appreciated
EDIT: if I change the line to the following, I am able to interact with the text field.
browser.driver.findElement(protractor.By.id('sample_ad_id')).sendKeys('batman');
hopefully this will help others....
Found this on github (see references link). The issue I believe is a script not returning, thus the sendKeys didn't work. Before interacting with the dom using protractor objects (element, ptor, etc), set this variable:
browser.ignoreSynchronization = true;
The reason the following works is because it doesn't rely on async calls, its just directly interacts with the dom and inserts the keys into the input field.
browser.driver.findElement(protractor.By.id('sample_ad_id')).sendKeys('batman');
The reason my call didn't work (I believe) is because there was an async call that didn't return in time.
element(by.model('sample_ad.id')).sendKeys('batman');
references:
https://github.com/angular/protractor/issues/325
See https://github.com/angular/protractor/blob/master/docs/faq.md#my-tests-time-out-in-protractor-but-everythings-working-fine-when-running-manually-whats-up
for more information on timeouts.
It looks like your test is timing out. The default timeout for protractor is 11 seconds.
Try setting a different timeout for this test:
it('should override timeout', function() {
// Timeout of 30 seconds.
element(by.model('sample_ad.id')).sendKeys('batman');
}, 30000)
You can also override the timeout for all your tests in the protractor configuration file. See this sample config file:
https://github.com/andresdominguez/protractor-meetup/blob/master/protractor-config.js#L19
// Inside the protractor config file.
onPrepare: function() {
// Override the timeout for webdriver.
var ptor = protractor.getInstance();
ptor.driver.manage().timeouts().setScriptTimeout(60000);
}