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

Replacement of named URL not working #2836

Closed
aybartsch opened this issue Jun 2, 2022 · 3 comments
Closed

Replacement of named URL not working #2836

aybartsch opened this issue Jun 2, 2022 · 3 comments

Comments

@aybartsch
Copy link

Hi there,
I have to deal with two different base url for the same environment. I tried the below solution:

Excerpt from serenity.conf:

        webdriver {
            base.url = "http://localhost:4200/tenants"
            support.base.url = "http://localhost:4210/tenants"
        }

Excerpt from step class:

supportTenantListPage.open("support", withParameters(EnvironmentVariablesHelper.getProperty("webdriver.support.base.url")));

Excerpt from page class:

@NamedUrls(value = {@NamedUrl(name = "support", url = "{1}")})

I was thinking that I could inject a different base url this way but I'm facing an assertion error instead:

java.lang.AssertionError: Invalid URL: {1}

	at net.serenitybdd.core.pages.PageUrls.updatedFullUrl(PageUrls.java:222)
	at net.serenitybdd.core.pages.PageUrls.addBaseUrlTo(PageUrls.java:206)
	at net.serenitybdd.core.pages.PageUrls.urlWithParametersSubstituted(PageUrls.java:180)
	at net.serenitybdd.core.pages.PageUrls.getNamedUrl(PageUrls.java:174)
	at net.serenitybdd.core.pages.PageObject.open(PageObject.java:768)
	at net.serenitybdd.core.pages.PageObject.open(PageObject.java:755)

Could you please tell me what is wrong and how I should do it correctly?
Thanks, André
PS: We are using serenity version 2.4.34 with cucumber runner at present.

@wakaleo
Copy link
Member

wakaleo commented Jun 2, 2022

That's a pretty old version. In general, the base url should be the hostname and port, with no paths (e.g. http://localhost:4200).

@aybartsch
Copy link
Author

aybartsch commented Jun 2, 2022

But we address the different base url by using different ports like 4200 and 4210. How would you overwrite the port within the named url?

@aybartsch
Copy link
Author

aybartsch commented Jun 2, 2022

FYI: I found a solution by kicking out webdriver.base.url and using @NamedUrl annotation instead:

Step class:

tenantListPage.open("local", withParameters(""));
tenantListPage.open("dev", withParameters(""));

Page class:

@NamedUrls(
        {
                @NamedUrl(name = "local", url = "<LOCAL-URL"),
                @NamedUrl(name = "dev", url = "<DEV-URL>"),
        }
)

Thank you John.

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