8000 [plugin-web-app] Align syntax of element steps by vkepin · Pull Request #4219 · vividus-framework/vividus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[plugin-web-app] Align syntax of element steps #4219

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

Merged
merged 1 commit into from
Sep 1, 2023

Conversation

vkepin
Copy link
Contributor
@vkepin vkepin commented Aug 10, 2023

No description provided.

@vkepin vkepin requested a review from a team as a code owner August 10, 2023 18:41
*/
@Deprecated(since = "0.6.0", forRemoval = true)
@Replacement(versionToRemoveStep = "0.8.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

to 0.7.0

@vkepin vkepin force-pushed the webapp_elem_steps branch from b1638b9 to b54f655 Compare August 11, 2023 09:13
@codecov
Copy link
codecov bot commented Aug 11, 2023

Codecov Report

Merging #4219 (8bc8aa5) into master (786aecb) will increase coverage by 0.00%.
The diff coverage is 95.55%.

@@            Coverage Diff            @@
##             master    #4219   +/-   ##
=========================================
  Coverage     97.21%   97.21%           
- Complexity     6362     6376   +14     
=========================================
  Files           889      889           
  Lines         18317    18356   +39     
  Branches       1210     1214    +4     
=========================================
+ Hits          17807    17845   +38     
  Misses          400      400           
- Partials        110      111    +1     
Files Changed Coverage Δ
...in/java/org/vividus/steps/ui/web/ElementSteps.java 96.72% <95.55%> (+0.33%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator
@valfirst valfirst left a comment

Choose a reason for hiding this comment

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

And also it makes sense to add/update docs

* relative paths</i></a>
* @throws IOException If an input or output exception occurred
*/
@When("I select element located by `$locator` and upload file `$filePath`")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@When("I select element located by `$locator` and upload file `$filePath`")
@When("I select element located by `$locator` and upload `$resourceNameOrFilePath`")

webDriverProvider.getUnwrapped(RemoteWebDriver.class).setFileDetector(new LocalFileDetector());
}
locator.getSearchParameters().setVisibility(Visibility.ALL);
baseValidations.assertElementExists(AN_ELEMENT, locator)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
baseValidations.assertElementExists(AN_ELEMENT, locator)
baseValidations.assertElementExists("A file input element", locator)

}
locator.getSearchParameters().setVisibility(Visibility.ALL);
baseValidations.assertElementExists(AN_ELEMENT, locator)
.ifPresent(browse -> browse.sendKeys(fullFilePath));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
.ifPresent(browse -> browse.sendKeys(fullFilePath));
.ifPresent(input -> input.sendKeys(fullFilePath));

public void hoverMouseOverElementByLocator(Locator locator)
{
baseValidations.assertElementExists(
String.format(AN_ELEMENT_WITH_ATTRIBUTES, locator), locator)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
String.format(AN_ELEMENT_WITH_ATTRIBUTES, locator), locator)
String.format("An element to hover mouse over", locator), locator)

@@ -197,7 +306,7 @@ public void doesEachElementByLocatorHaveChildWithLocator(Locator elementLocator,
* @param cssName A name of the <b>CSS property</b>
* @param cssValue An expected value of <b>CSS property</b>
*/
@Then("the context element has the CSS property '$cssName'='$cssValue'")
@Then("context element has CSS property `$cssName`=`$cssValue`")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@Then("context element has CSS property `$cssName`=`$cssValue`")
@Then("context element has CSS property `$cssName` with value that $comparisonRule `$cssValue`")

where $comparisonRule is StringComparisonRule

* @param cssName A name of the <b>CSS property</b>
* @param cssValue An expected value part of <b>CSS property</b>
*/
@Then("context element has CSS property `$cssName` containing `$cssValue`")
Copy link
Collaborator

Choose a reason for hiding this comment

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

see the comment above, it would be enough to have only 1 step

@@ -260,7 +388,7 @@ public boolean doesEachElementByLocatorHaveSameDimension(Locator locator, Dimens
* has an expected <b>width in a percentage</b> (from style attribute)
* @param widthInPerc An expected width of the element in a percentage
*/
@Then("the context has a width of '$widthInPerc'%")
@Then("context has width of `$widthInPerc`%")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@Then("context has width of `$widthInPerc`%")
@Then("context element has width of $widthPercentage%")

* Checks, if the context element has specified width in percentage
* @param width Expected element with in percentage
*/
@Then("context element has width of `$widthInPerc`% relative to parent element")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@Then("context element has width of `$widthInPerc`% relative to parent element")
@Then("context element has width of $widthPercentage% relative to parent element")

+ " after clicking on the element located by";
private static final String ELEMENT_CSS_CONTAINING_VALUE = "Element has CSS property '%s' containing value '%s'";
private static final String PARENT_ELEMENT_XPATH = "./..";
private static final String PARENT_ELEMENT = "Parent element";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
private static final String PARENT_ELEMENT = "Parent element";
private static final String PARENT_ELEMENT = "The parent element";

@vkepin vkepin force-pushed the webapp_elem_steps branch 2 times, most recently from f5c4e17 to c43c2aa Compare August 16, 2023 21:59
}
File fileForUpload = ResourceUtils.isFileURL(resource.getURL()) ? resource.getFile()
: unpackFile(resource, filePath);
if (descriptiveSoftAssert.assertTrue(String.format(FILE_EXISTS_MESSAGE_FORMAT, filePath),
Copy link
Member
@uarlouski uarlouski Aug 17, 2023

Choose a reason for hiding this comment

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

we removed file from step naming as per @valfirst comment (imho its weird because each resource is a file and step naming doesn't look good anymore) but inside step we still use "file" in messages

Copy link
Collaborator

Choose a reason for hiding this comment

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

each resource is a file

nope

step naming doesn't look good anymore

we are adhering common naming: https://docs.vividus.dev/vividus/0.5.13/commons/expressions.html#_calculatefilehash

Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. as for the message: it makes sense to update it and make more descriptive
  2. no need to use softAssert to check file/resource presence: we can throw exception in case of invalid input - it's considered as user's mistake

*/
@Deprecated(since = "0.6.0", forRemoval = true)
@Replacement(versionToRemoveStep = "0.7.0",
replacementFormatPattern = "Then context element has width of %1$s% relative to parent element")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
replacementFormatPattern = "Then context element has width of %1$s% relative to parent element")
replacementFormatPattern = "Then context element has width of %1$s%% relative to parent element")

if (!resource.exists())
{
resource = resourceLoader.getResource(ResourceUtils.FILE_URL_PREFIX + filePath);
}
Copy link
Member

Choose a reason for hiding this comment

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

wonder if we can encounter collision when both resource and file exist, the change is nearly 0 but probably we can handle it

Copy link
Collaborator

Choose a reason for hiding this comment

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

no reason, we always start search in resources

Copy link
Collaborator

Choose a reason for hiding this comment

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

if needed it can be explicitly described in docs/javadocs

@When("I click on element located by `$locator` then page does not refresh")
public void clickElementAndPageNotRefresh(Locator locator)
{
baseValidations.assertElementExists(AN_ELEMENT_TO_CLICK, locator).ifPresent(element ->
Copy link
Member

Choose a reason for hiding this comment

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

replacing this block with map map would look prettier

* <li>Clicks on the element;</li>
* <li>Assert that page has not been refreshed after click</li>
* </ul>
* @param locator to locate element
Copy link
Member

Choose a reason for hiding this comment

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

@param locator The locator for the upload element
and in other places

@vkepin vkepin force-pushed the webapp_elem_steps branch 2 times, most recently from 66f7d78 to 053df57 Compare August 28, 2023 16:33
@@ -299,6 +299,294 @@ When I scan barcode from context and save result to scenario variable `qrCodeLin
Then `${qrCodeLink}` is equal to `https://www.example.com`
----

=== Element Steps
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
=== Element Steps

Comment on lines 306 to 308
This step uploads a file with the given relative path.

NOTE: A relative path starts from some given working directory, avoiding the need to provide the full absolute path (i.e. 'about.jpeg' for the files placed in the src/main/resources directory or '/story/uploadfiles/about.png')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This step uploads a file with the given relative path.
NOTE: A relative path starts from some given working directory, avoiding the need to provide the full absolute path (i.e. 'about.jpeg' for the files placed in the src/main/resources directory or '/story/uploadfiles/about.png')
Uploads the {xref:ROOT:glossary.adoc#_resource}[resource] or file via web interface.

When I select element located `$locator` and upload file `$filePath`
----

* `$locator` - The <<_locator,locator>> to find an element.
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 mention it's required to specify locator for input element with attribute type=file

.Upload file_for_upload.png file
[source,gherkin]
----
When I select element located `By.id(uploadfile)` and upload file `/folder/file_for_upload.png`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
When I select element located `By.id(uploadfile)` and upload file `/folder/file_for_upload.png`
When I select element located by `id(uploadfile)` and upload file `/folder/file_for_upload.png`


=== Verify page is not refreshed after click on element

This step clicks on the element and checks that the page has not been refreshed after clicking.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This step clicks on the element and checks that the page has not been refreshed after clicking.
Clicks on the element and checks that the page has not been refreshed after the click.


=== Check an element CSS property

Check that the context element has an expected CSS property.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Check that the context element has an expected CSS property.
Checks the context element has the expected CSS property.


Check that the context element has an expected CSS property.

The context can be set by the <<_change_context,corresponding steps>>. If no context is set, the text will be searched on the whole page.
Copy link
Collaborator

Choose a reason for hiding this comment

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

we do not search text in this step

Comment on lines 552 to 555
Then the context has a width of '$widthInPerc'%
----

* `$widthInPerc` - An expected element width in a percentage.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Then the context has a width of '$widthInPerc'%
----
* `$widthInPerc` - An expected element width in a percentage.
Then the context has a width of '$widthPercentage'%
----
* `$widthPercentage ` - An expected element width in a percentage.


Checks that the context element has an expected *width in a percentage* (from the style attribute) relative to the parent element

The context can be set by the <<_change_context,corresponding steps>>. If no context is set, the text will be searched on the whole page.
Copy link
Collaborator

Choose a reason for hiding this comment

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

no text search in this step

Comment on lines 578 to 581
Then the context element has a width of '$widthInPerc'% relative to the parent element
----

* `$widthInPerc` - An expected element width in a percentage.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Then the context element has a width of '$widthInPerc'% relative to the parent element
----
* `$widthInPerc` - An expected element width in a percentage.
Then the context element has a width of '$widthPercentage'% relative to the parent element
----
* `$widthPercentage ` - An expected element width in a percentage.

@vkepin vkepin force-pushed the webapp_elem_steps branch from 053df57 to 400518e Compare August 29, 2023 16:26
Then each element located `id(context-menu-item)` has same `height`
----

=== Check element width in a percentage
Copy link
Member

Choose a reason for hiding this comment

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

in this case the width is calculated relatively to body, please add this in docs

B83A
File fileForUpload = ResourceUtils.isFileURL(resource.getURL()) ? resource.getFile()
: unpackFile(resource, filePath);
Validate.isTrue(fileForUpload.exists(), FILE_EXISTS_MESSAGE_FORMAT, filePath);
String fullFilePath = fileForUpload.getAbsolutePath();
Copy link
Member

Choose a reason for hiding this comment

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

inline or bring it closed to the place where its used?

@vkepin vkepin force-pushed the webapp_elem_steps branch 2 times, most recently from edaa711 to 69d0643 Compare August 31, 2023 09:32
@uarlouski uarlouski self-requested a review August 31, 2023 12:17
@valfirst valfirst merged commit f42c331 into vividus-framework:master Sep 1, 2023
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

Successfully merging this pull request may close these issues.

3 participants
0