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

Update syntax for "When I go to the relative URL '$relativeURL'" step #3516

Merged
merged 3 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion docs/modules/plugins/partials/plugin-web-app-steps.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:popup-alert: https://www.w3schools.com/js/js_popup.asp
:close-spec: https://w3c.github.io/webdriver/webdriver-spec.html#close-window[close]

=== Page steps
=== Steps opening pages

==== Open main application page

Expand Down Expand Up @@ -36,6 +36,54 @@ Given I am on page with URL `$pageURL`
Given I am on page with URL `https://docs.vividus.dev/`
----

==== Open page with relative URL

Navigates the browser to the specific path in the current host defined in the _relative URL_ step parameter.

A relative URL can point to a file within a web site (like `about.html` or `/products`).

- If the parameter starts with '/' char, navigation will be performed from the root of the host, see examples below.
- If the parameter starts without '/' char or with './', navigation will be performed from the current path directory.

.Examples
|===
|Current page |Relative URL parameter|Opened page

|https://mysite.com
|about.html
|https://mysite.com/about.html

|https://mysite.com
|/products/new
|https://mysite.com/products/new

|https://mysite.com/path/foo
|stats
|https://mysite.com/path/foo/stats

|https://mysite.com/path/foo
|./docs/info.html
|https://mysite.com/path/foo/docs/info.html

|https://mysite.com/path/foo
|/documents
|https://mysite.com/documents
|===

[source,gherkin]
----
When I go to relative URL `$relativeURL`
----

* `relativeURL` - A string value of the relative URL.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also please add example demoing step usage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still looking for examples

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

. Open main application page and then navigate to '/products/new' page on the application host
[source,gherkin]
----
Given I am on main application page
When I go to relative URL `/products/new`
----

=== Clicking steps

==== Click on element
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,24 @@ public void isPageScrolledToAnElement(Locator locator)
}

/**
* Goes to the relative URL
* Navigates the browser to the specific path in the current host
* defined in the <i>relative URL</i> step variable
* <br>
* A <b>relative URL</b> - points to a file within a web site (like <i>'about.html'</i> or <i>'/products'</i>)<br>
* A <b>relative URL</b> - points to a file within a web site
* (like <i>'about.html'</i> or <i>'/products'</i>)<br>
* <p>
* <table border="1">
* <caption>Examples:</caption>
* <tr>
* <td>Current page</td><td>Relative URL parameter</td><td>Opened page</td>
* </tr>
* <tr>
* <td>https://mysite.com/path/foo</td><td>stats</td><td>https://mysite.com/path/stats</td>
* </tr>
* <tr>
* <td>https://mysite.com/path/foo</td><td>/documents</td><td>https://mysite.com/documents</td>
* </tr>
* </table>
* <p>
* Actions performed at this step:
* <ul>
Expand All @@ -249,8 +264,8 @@ public void isPageScrolledToAnElement(Locator locator)
* <p>
* @param relativeURL A string value of the relative URL
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't forget to sync javadoc with main docs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@When("I go to the relative URL '$relativeURL'")
public void iGoTo(String relativeURL)
@When("I go to relative URL `$relativeURL`")
public void openRelativeUrl(String relativeURL)
{
setContextSteps.switchingToDefault();
URI currentURI = UriUtils.createUri(getWebDriver().getCurrentUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,7 @@ Given I am on main application page
Composite: Given I am on a page with the URL '$pageURL'
!-- WARNING: The step "Given I am on a page with the URL '$pageURL'" is deprecated and will be removed in VIVIDUS 0.7.0
Given I am on page with URL `<pageURL>`

Composite: When I go to the relative URL '$relativeURL'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to have tests for both new and deprecated steps, so please either add new test or change some existing one to check behaviour of the new step

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

!-- WARNING: The step "When I go to the relative URL '$relativeURL'" is deprecated and will be removed in VIVIDUS 0.7.0
When I go to relative URL `<relativeURL>`
Original file line number Diff line number Diff line change
Expand Up @@ -224,32 +224,32 @@ void testIsElementAtTheTopElementNull()
// @formatter:on
// CHECKSTYLE:ON
})
void testIGoTo(String baseUrl, String toGo, String expected)
void testOpenRelativeUrl(String baseUrl, String toGo, String expected)
{
when(webDriverProvider.get()).thenReturn(driver);
when(driver.getCurrentUrl()).thenReturn(baseUrl);
pageSteps.iGoTo(toGo);
pageSteps.openRelativeUrl(toGo);
verify(setContextSteps).switchingToDefault();
verify(navigateActions).navigateTo(expected);
}

@Test
void testIGoToIOS()
void testOpenRelativeUrlIOS()
{
when(webDriverProvider.get()).thenReturn(driver);
when(driver.getCurrentUrl()).thenReturn(URL);
when(webDriverManager.isIOS()).thenReturn(true);
pageSteps.iGoTo(RELATIVE_URL);
pageSteps.openRelativeUrl(RELATIVE_URL);
verify(waitActions).waitForPageLoad();
}

@Test
void testIGoToNotIOS()
void testOpenRelativeUrlNotIOS()
{
when(webDriverProvider.get()).thenReturn(driver);
when(driver.getCurrentUrl()).thenReturn(URL);
when(webDriverManager.isIOS()).thenReturn(false);
pageSteps.iGoTo(RELATIVE_URL);
pageSteps.openRelativeUrl(RELATIVE_URL);
verifyNoInteractions(waitActions);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ Meta:

Lifecycle:
Examples:
|windowsTitle|indexTitle |vivdus-test-site |
|Windows |Vividus Test Site|${vividus-test-site-url}/windows.html|
|windowsTitle|indexTitle |
|Windows |Vividus Test Site|


Scenario: Verify step with "is equal to": "When I switch to window with title that $stringComparisonRule `$title`"
Given I am on page with URL `<vivdus-test-site>`
Given I am on page with URL `${vividus-test-site-url}/windows.html`
Then the page title is equal to '<windowsTitle>'
When I click on element located by `id(plain)`
When I switch to window with title that is equal to `<indexTitle>`
Expand All @@ -17,8 +17,9 @@ When I close the current window
Then the page title is equal to '<windowsTitle>'


Scenario: Verify step with "contains": "When I switch to window with title that $stringComparisonRule `$title`"
Given I am on page with URL `<vivdus-test-site>`
Scenario: Verify steps: with "contains": "When I switch to window with title that $stringComparisonRule `$title`" and "When I go to relative URL `$relativeURL`"
Given I am on main application page
When I go to relative URL `/windows.html`
Then the page title is equal to '<windowsTitle>'
When I click on element located by `id(plain)`
When I switch to window with title that contains `<indexTitle>`
Expand All @@ -27,8 +28,9 @@ When I close the current window
Then the page title is equal to '<windowsTitle>'


Scenario: Verify step: "When I wait `$duration` until window with title that $comparisonRule `$windowTitile` appears and switch to it"
Given I am on page with URL `<vivdus-test-site>`
Scenario: Verify steps: "When I wait `$duration` until window with title that $comparisonRule `$windowTitile` appears and switch to it" and "When I go to relative URL `$relativeURL`"
Given I am on main application page
When I go to the relative URL 'windows.html'
Then the page title is equal to '<windowsTitle>'
When I click on element located by `id(timeout)`
When I wait `PT3S` until window with title that is equal to `<indexTitle>` appears and switch to it
Expand Down