Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serenity Unit tests fail when using @DefaultUrl("classpath:<static-site.html>") #595

Closed
nbarrett opened this issue Nov 9, 2016 · 2 comments

Comments

@nbarrett
Copy link
Contributor

nbarrett commented Nov 9, 2016

If I wish to create some unit tests to TDD my page objects, and I use the following static website pattern:

@DefaultUrl("classpath:static-site/error-modal-on-search/my-application.html")
public class SearchResultsErrorModalPage extends PageObject {
}

and then reference this as follows:

    @Managed(driver = "htmlunit")
    WebDriver browser;
    Actor actor = new Actor("MDM");
    actor.can(BrowseTheWeb.with(browser));

    SearchResultsErrorModalPage searchResultsErrorModalPage;
    givenThat(actor).attemptsTo(Open.browserOn().the(searchResultsErrorModalPage));

I find that when I run @Test cases individually, they work fine but when I run the whole test class or run all tests in the suite some fail. The nature of failure is that the website I expect to be there is not being rendered properly. Is there a different way to scope/instantiate the page object correctly/reliably?

@wakaleo
Copy link
Member

wakaleo commented Nov 9, 2016

Could be an HtmlUnit bug, have you tried with other drivers?

@nbarrett
Copy link
Contributor Author

nbarrett commented Nov 9, 2016

hmm, no it actually fails on all browsers. Error is org.openqa.selenium.NoSuchElementException: Returned node was not a DOM element, Say 1 out of 4 tests fail - oddly enough it's the last one each time!

image

I see this sometimes when I run all tests in net.serenitybdd.screenplay.webtests directory in the serenity-screenplay-webdriver project which also use the static html site pattern.

@nbarrett nbarrett changed the title Serenity Unit tests fail when run in suite Serenity Unit tests fail when using @DefaultUrl("classpath:static-site...) Jan 12, 2017
@nbarrett nbarrett changed the title Serenity Unit tests fail when using @DefaultUrl("classpath:static-site...) Serenity Unit tests fail when using @DefaultUrl("classpath:<static-site.html>") Jan 12, 2017
@wakaleo wakaleo closed this as completed Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants