question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Element.isPresent() script timeout

See original GitHub issue

Hi!

I have an issue using protractor with jasmine, and I wonder if there is an issue with the framework, or if my limited knowledge of the framework plays against me. I found a fairly recent StackOverflow question with four upvotes but no answer so far, which leads me to think that something may be going wrong with the latest version of protractor.

Here is my test:

import {
	browser,
	ExpectedConditions,
	$
} from 'protractor';

describe('When user click \"Test\" button', async () => {
  beforeAll(async () => {
    await browser.get('http://local.myawesomewebsite.com:4200');
    expect(await browser.getCurrentUrl())
		.toContain('myawesomewebsite');
		browser.waitForAngularEnabled(true);
  });

  it ("should navigate to next page", async () => {
		var testButton = $(".wrapper button");
		browser.wait(
			ExpectedConditions.presenceOf(testButton),
			5000,
			'Element taking too long to appear in the DOM'
		);
		expect(await testButton.isPresent())
		.toBe(true);
		await testButton.click();
  });

	describe("When user click button to open modal", async () => {
		beforeAll(() => {
			expect(browser.getCurrentUrl())
			.toContain('next/page');
		});

		it("should make modal appear", async () => {
			var popModalButton 	= await $(".wrapper button");
			var overlay			= await $('.overlay.active');

			browser.wait(
				ExpectedConditions.presenceOf(popModalButton),
				5000,
				'Element taking too long to appear in the DOM'
			);

			expect(await popModalButton.isPresent())
			.toBe(true);
			await popModalButton.click();
		});

		describe("When user clicks modal button", async () => {
			it("should proceed to final page", async () => {
				var proceedToFinalPageButton = await $(".cta.modal-not-empty button.continue-to-final-page");

				await browser.wait(
					ExpectedConditions.presenceOf(proceedToFinalPageButton),
					5000,
					'Element taking too long to appear in the DOM'
				);
				expect(await proceedToFinalPageButton.isPresent())
				.toBe(true);
			});
		});
	});
});

It all works great until the test reach the last attempt to detect if the modal popped out:

await browser.wait(
    ExpectedConditions.presenceOf(proceedToFinalPageButton),
    5000,
    'Element taking too long to appear in the DOM'
);
expect(await proceedToFinalPageButton.isPresent())
.toBe(true);

This isPresent() doesn’t return true or false, instead nothing happens and protractor stops and outputs the following error:

Failed: script timeout: result was not received in 11 seconds

Any idea what could be going wrong? Thanks!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:7
  • Comments:9

github_iconTop GitHub Comments

1reaction
gabriellegulczynskicommented, May 24, 2019

This just started happening for me. It’s very inconsistent. Sometimes it works for a decent amount of time and then sometimes it just keeps failing over and over. Are there any plans to fix this?

1reaction
a-stanglcommented, Feb 15, 2019

I experience more or less the same, I think it’s related to browser.waitForAngularEnabled

  • I need to login on a separate angular 7 app
  • once I logged in there I want to test the “main app” that’s also using angular 7

If I globally do browser.waitForAngularEnabled(false) I can test both apps, but then I always have to “manually” wait until angular was fully loaded.

So I tried to browser.waitForAngularEnabled(false) while I login in App 1 and browser.waitForAngularEnabled(true) after I logged in there, then I want to redirect to the main app and do my testing. The result is the issue OP reported above.

Looks like toggling browser.waitForAngularEnabled does not really work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

protractor, script timeout after login procedure
isPresent(), so this is an easy question for the browser, and it just replies "no" since it is most likely not ... expect(await...
Read more >
isPresent | API Reference
Determines if an element is present in the DOM. The command isPresent() will automatically wait for the element to be present (until the...
Read more >
How do these failure durations make sense?
When it fails, it claims it was a ScriptTimeoutError and the timed out step is the one immediately after it switches to the...
Read more >
angular/protractor
I extended the script timeout in the protractor config to 30 seconds in fear that the page was ... It won't be an...
Read more >
Check Visibility of Web Elements Using Various Types ...
isEnabled() is the method used to verify if the web element is enabled ... Implementation of Our First WebDriver Script – Selenium WebDriver ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found