Skip to content

Commit

Permalink
[plugin-web-app] Remove deprecated wait steps (#4226)
Browse files Browse the repository at this point in the history
Co-authored-by: draker94 <noreply@github.com>
  • Loading branch information
draker94 and web-flow authored Aug 15, 2023
1 parent def19d3 commit b06dc7c
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 280 deletions.
46 changes: 2 additions & 44 deletions docs/modules/plugins/pages/plugin-web-app.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -950,67 +950,25 @@ Then `${response}` matcher `.+`

=== Element wait steps

:disappearance-check-note: If the element doesn't exist on the page/context, the step will immediately complete successfully. Checking the element on the page (if needed) should be done in a separate step (e.g. <<_wait_for_element_appearance>> or xref:plugin-html.adoc#_validate_elements[Validate elements]).

==== Wait for disappearance of an element with a tag

[WARNING]
====
The step is deprecated and will be removed in VIVIDUS 0.6.0.
The replacement is a <<_wait_for_element_disappearance,generic step waiting for element disappearance>>.
====

Waits for an element with the specified tag, attribute type and value disappearance.

Actions performed by step:

* Searches for an element with the specified attribute and tag within search context
* If there are no elements by specified attribute and tag, step provides passed assertion and don't check disappearance of an element
* If there are elements by specified attribute and tag, waits until this element becomes not visible

NOTE: {disappearance-check-note}

[source,gherkin]
----
When I wait until an element with the tag '$elementTag' and attribute '$attributeType'='$attributeValue' disappears
----

* `$elementTag` - Type of the https://www.w3schools.com/TAgs/default.asp[html tag] (e.g. `div` or `iframe`).
* `$attributeType` - Type of the https://www.w3schools.com/html/html_attributes.asp[tag attribute] (e.g. `name` or `id`).
* `$attributeValue` - Value of the attribute.

.Click on the button and waiting for disappearance of the `div` element with a certain attribute and value
[source,gherkin]
----
When I click on a button with the name 'Toggle element visibility with delay'
When I wait until an element with the tag 'div' and attribute 'id'='delayed' disappears
----

==== Wait for element disappearance with timeout

Waits for element disappearance with desired timeout.

NOTE: {disappearance-check-note}
NOTE: If the element doesn't exist on the page/context, the step will immediately complete successfully. Checking the element on the page (if needed) should be done in a separate step (e.g. <<_wait_for_element_appearance>> or xref:plugin-html.adoc#_validate_elements[Validate elements]).

[source,gherkin]
----
Then element located by `$locator` disappears in `$timeout`
----

_Deprecated syntax (will be removed in VIVIDUS 0.6.0)_:
[source,gherkin]
----
Then element located '$locator' disappears in '$timeout'
----

* `$locator` - The <<_locator,locator>> used to element.
* `$timeout` - The maximum time to wait for the element disappearance in {durations-format-link} format.

.Click on the button and waiting for disappearance of the element for 3 seconds
[source,gherkin]
----
When I click on a button with the name 'Toggle element visibility with delay'
Then element located 'By.xpath(//div[@id='delayed'])' disappears in 'PT3S'
Then element located by 'xpath(//div[@id='delayed'])' disappears in 'PT3S'
----

=== Set Variable Steps
Expand Down
6 changes: 0 additions & 6 deletions docs/modules/plugins/partials/generic-ui-steps.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@ Waits for an element with the specified state to be found using the specified ti
When I wait `$duration` with `$pollingDuration` polling until element located by `$locator` becomes $state
----

_Deprecated syntax (will be removed in VIVIDUS 0.6.0)_:
[source,gherkin]
----
When I wait `$duration` with `$pollingDuration` polling until element located `$locator` becomes $state
----

* `$duration` - Total duration to wait in the {iso-date-format-link} format.
* `$pollingDuration` - The duration to wait between search retries in the {iso-date-format-link} format.
* `$locator` - The <<_locator,locator>> of the element to wait for state change.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,3 @@ When I change context to element located by `<locator>` in scope of current cont
Composite: When I take screenshot and save it to folder `$screenshotFilePath`
!-- DEPRECATED: 0.7.0, When I take screenshot and save it to file at path `%1$s`
When I take screenshot and save it to file at path `<screenshotFilePath>`

Composite: When I wait `$duration` with `$pollingDuration` polling until element located `$locator` becomes $state
!-- DEPRECATED: 0.6.0, When I wait `%1$s` with `%2$s` polling until element located by `%3$s` becomes %4$s
When I wait `<duration>` with `<pollingDuration>` polling until element located by `<locator>` becomes <state>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static org.openqa.selenium.support.ui.ExpectedConditions.titleIs;

import java.time.Duration;
import java.util.List;

import javax.inject.Inject;

Expand All @@ -35,34 +34,27 @@
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vividus.annotation.Replacement;
import org.vividus.selenium.IWebDriverProvider;
import org.vividus.selenium.TimeoutConfigurer;
import org.vividus.softassert.ISoftAssert;
import org.vividus.steps.ui.validation.IBaseValidations;
import org.vividus.ui.State;
import org.vividus.ui.action.IExpectedConditions;
import org.vividus.ui.action.ISearchActions;
import org.vividus.ui.action.IWaitActions;
import org.vividus.ui.action.WaitResult;
import org.vividus.ui.action.search.Locator;
import org.vividus.ui.context.IUiContext;
import org.vividus.ui.monitor.TakeScreenshotOnFailure;
import org.vividus.ui.util.XpathLocatorUtils;
import org.vividus.ui.web.action.WebJavascriptActions;
import org.vividus.ui.web.action.search.WebLocatorType;

@TakeScreenshotOnFailure
public class WaitSteps
{
private static final long DIVISOR = 10;
private static final Logger LOGGER = LoggerFactory.getLogger(WaitSteps.class);

@Inject private IWebDriverProvider webDriverProvider;
@Inject private IWaitActions waitActions;
@Inject private ISearchActions searchActions;
@Inject private IUiContext uiContext;
@Inject private ISoftAssert softAssert;
@Inject private IExpectedConditions<By> expectedSearchContextConditions;
Expand All @@ -71,78 +63,6 @@ public class WaitSteps
@Inject private WebJavascriptActions javascriptActions;
@Inject private TimeoutConfigurer timeoutConfigurer;

/**
* @deprecated Use step: "When I wait until element located by `$locator` disappears"
*
* Waits for <b><i>an element</i></b> with the specified <b>tag</b> and <b>attribute type and value</b>
* disappearance in the specified search context
* <p>
* Actions performed at this step:
* </p>
* <ul>
* <li><b>Searches</b> for an element with the <b>specified attribute and tag</b> within search context</li>
* <li><i>If there are <b>no elements</b> by specified attribute and tag</i>, step provides passed assertion and
* don't check disappearance of an element</li>
* <li><i>If <b>there are elements</b> by specified attribute and tag, </i><b>waits</b> until this element becomes
* not visible</li>
* </ul>
* @param elementTag Type of the html tag (for ex. &lt;div&gt;, &lt;iframe&gt;)
* @param attributeType Type of the tag attribute (for ex. 'name', 'id')
* @param attributeValue Value of the attribute
*/
@Deprecated(since = "0.5.1", forRemoval = true)
@When("I wait until an element with the tag '$elementTag' and attribute"
+ " '$attributeType'='$attributeValue' disappears")
public void waitTillElementDisappears(String elementTag, String attributeType, String attributeValue)
{
LOGGER.warn("The step: \"When I wait until an element with the tag '$elementTag' and attribute '$attributeType'"
+ "='$attributeValue' disappears\" is deprecated and will be removed in VIVIDUS 0.6.0."
+ " Use step: \"When I wait until element located by `$locator` disappears\"");
String elementXpath = XpathLocatorUtils.getXPathByTagNameAndAttribute(elementTag, attributeType,
attributeValue);
Locator locator = new Locator(WebLocatorType.XPATH, elementXpath);
locator.getSearchParameters().setWaitForElement(false);
List<WebElement> elements = searchActions.findElements(locator);
if (!elements.isEmpty())
{
waitActions.wait(getWebDriver(), State.NOT_VISIBLE.getExpectedCondition(elements.get(0)));
}
else
{
String assertionDescription = "There is no element present with the tag '%s' and attribute '%s'='%s'";
String description = String.format(assertionDescription, elementTag, attributeType, attributeValue);
softAssert.recordPassedAssertion(description);
}
}

/**
* @deprecated Use step: "When I wait until element located by `$locator` appears"
*
* Waits for <b><i>an element</i></b> with the specified <b>tag</b> and <b>attribute type and value</b>
* appearance in the specified search context
* <p>
* Actions performed at this step:
* </p>
* <ul>
* <li><i>Finds</i> an element with the <b>specified attribute and tag</b> within search context
* <li><i>Waits</i> until this element becomes visible
* </ul>
* @param elementTag Type of the html tag (for ex. &lt;div&gt;, &lt;iframe&gt;)
* @param attributeType Type of the tag attribute (for ex. 'name', 'id')
* @param attributeValue Value of the attribute
*/
@Deprecated(since = "0.5.1", forRemoval = true)
@When("I wait until an element with the tag '$elementTag' and attribute"
+ " '$attributeType'='$attributeValue' appears")
public void waitTillElementAppears(String elementTag, String attributeType, String attributeValue)
{
LOGGER.warn("The step: \"When I wait until an element with the tag '$elementTag' and attribute "
+ "'$attributeType'='$attributeValue' appears\" is deprecated and will be removed in VIVIDUS 0.6.0."
+ " Use step: \"When I wait until element located by `$locator` appears\"");
waitForElementAppearance(getSearchContext(),
By.xpath(XpathLocatorUtils.getXPathByTagNameAndAttribute(elementTag, attributeType, attributeValue)));
}

/**
* Waits for <b><i>an alert</i></b> appearance on the page
* <p>
Expand Down Expand Up @@ -308,24 +228,6 @@ public void waitTillFrameAppears(String frameName)
);
}

/**
* @deprecated Use step: "When I wait until element located by `$locator` disappears"
*
* Waits for <b><i>an element</i></b> with the specified <b>id</b> disappearance
* in the specified search context
* @param id Value of the 'id' attribute of the element
*/
@Deprecated(since = "0.5.1", forRemoval = true)
@Then("an element with the id '$id' disappears")
@Replacement(versionToRemoveStep = "0.6.0",
replacementFormatPattern = "When I wait until element located by `id(%1$s)` disappears")
public void elementByIdDisappears(String id)
{
By locator = By.xpath(XpathLocatorUtils.getXPathByAttribute("id", id));
waitActions.wait(getSearchContext(),
State.NOT_VISIBLE.getExpectedCondition(expectedSearchContextConditions, locator));
}

/**
* Checks that no alert displayed during the <b><i>timeout</i></b>.
* Makes {@value #DIVISOR} attempts to confirm alert displaying at regular intervals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,54 +164,6 @@ Then number of elements found by `By.xpath(.//button[./img[@src='<imageSrc>']])`
Composite: Then a button with the tooltip '$tooltip' and image with the src '$imageSrc' exists
Then number of elements found by `By.xpath(.//button[./img[@src='<imageSrc>'] and @title='<tooltip>'])` is equal to `1`

Composite: When I wait until an element with the text '$text' appears
!-- DEPRECATED: 0.6.0, When I wait until element located by `caseSensitiveText(%1$s)` appears
When I wait until element located by `caseSensitiveText(<text>)` appears

Composite: When I wait until an element with the text '$text' disappears
!-- DEPRECATED: 0.6.0, When I wait until element located by `caseSensitiveText(%1$s)` disappears
When I wait until element located by `caseSensitiveText(<text>)` disappears

Composite: When I wait until an element with the name '$elementName' disappears
!-- DEPRECATED: 0.6.0, When I wait until element located by `elementName(%1$s)` disappears
When I wait until element located by `elementName(<elementName>)` disappears

Composite: When I wait until an element with the name '$elementName' appears
!-- DEPRECATED: 0.6.0, When I wait until element located by `elementName(%1$s)` appears
When I wait until element located by `elementName(<elementName>)` appears

Composite: When I wait until the state of an element with the name '$elementName' becomes [$state]
!-- DEPRECATED: 0.6.0, When I wait until state of element located by `elementName(%1$s)` is %2$s
When I wait until state of element located by `elementName(<elementName>)` is <state>

Composite: When I wait until an element with the name '$elementName' is stale
!-- DEPRECATED: 0.6.0, When I wait until element located by `elementName(%1$s)` is stale
When I wait until element located by `elementName(<elementName>)` is stale

Composite: When I wait until an element with the name '$elementName' contains the text '$text'
!-- DEPRECATED: 0.6.0, When I wait until element located by `elementName(%1$s)` contains text `%2$s`
When I wait until element located by `elementName(<elementName>)` contains text `<text>`

Composite: Then an element with the name '$elementName' disappears in '$timeout' seconds
!-- DEPRECATED: 0.6.0, Then element located by `elementName(%1$s)` disappears in `%2$s`
Then element located by `elementName(<elementName>)` disappears in `<timeout>`

Composite: When I wait until state of element located `$locator` is $state
!-- DEPRECATED: 0.6.0, When I wait until state of element located by `%1$s` is %2$s
When I wait until state of element located by `<locator>` is <state>

Composite: When I wait until element located `$locator` is stale
!-- DEPRECATED: 0.6.0, When I wait until element located by `%1$s` is stale
When I wait until element located by `<locator>` is stale

Composite: When I wait until element located `$locator` contains text '$text'
!-- DEPRECATED: 0.6.0, When I wait until element located by `%1$s` contains text `%2$s`
When I wait until element located by `<locator>` contains text `<text>`

Composite: Then element located '$locator' disappears in '$timeout'
!-- DEPRECATED: 0.6.0, Then element located by `%1$s` disappears in `%2$s`
Then element located by `<locator>` disappears in `<timeout>`

Composite: Given I am on the main application page
!-- DEPRECATED: 0.7.0, Given I am on main application page
Given I am on main application page
Expand Down
Loading

0 comments on commit b06dc7c

Please sign in to comment.