8000 [plugin-web-app] Use `tab` instead of `window` in steps syntax by vkepin · Pull Request #3857 · 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] Use tab instead of window in steps syntax #3857

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
Jun 28, 2023

Conversation

vkepin
Copy link
Contributor
@vkepin vkepin commented Apr 19, 2023

No description provided.

@vkepin vkepin requested a review from a team as a code owner April 19, 2023 20:43
@@ -129,6 +129,8 @@ public void switchingToFrame(Locator locator)
* reference</i></a>
*/
@When("I switch to a new window")
// @When("I switch to a new tab")
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 switch to a new tab")
// @When("I switch to new tab")

@@ -164,6 +169,7 @@ public void closeCurrentWindowWithAlertsHandling()
});
}

//TODO: rename? tryToCloseCurrentTab(BiConsumer<WebDriver, String> closeExecutor)
Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, rename please

String switchToWindowWithMatchingTitle(Matcher<String> matcher);

/**
* Switches to a previous window
*/
// rename? switchToPreviousTab();
Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, rename all methods

@@ -31,6 +31,8 @@
import org.vividus.selenium.IWebDriverProvider;
import org.vividus.selenium.manager.IWebDriverManager;

// update according changes in IWindowsActions + update messages in methods
// private methods renaming?
Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, full renaming

@@ -51,6 +51,7 @@ public void afterNavigateTo(String url, WebDriver driver)
resetPerformanceMetrics();
}

// Should update to tab?
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think that's possible, it's an implementation of Selenium interface

@vkepin vkepin force-pushed the upd_webapp_tabs_steps branch from d243342 to 6c8f1c8 Compare April 24, 2023 17:03
if (descriptiveSoftAssert.assertThat(String.format("New window '%s' is found", newWindow),
"New window is found", newWindow, not(equalTo(currentWindow))))
{
resetContext();
}
}

/**
* Switch the focus of future browser commands to the new <b>window object</b>.
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's avoid window in javadocs and docs

@vkepin vkepin force-pushed the upd_webapp_tabs_steps branch 5 times, most recently from 9e14380 to 1bb7371 Compare May 19, 2023 07:33
@codecov
Copy link
codecov bot commented May 19, 2023

Codecov Report

Merging #3857 (1bb7371) into master (0e0420c) will decrease coverage by 0.03%.
The diff coverage is 98.18%.

❗ Current head 1bb7371 differs from pull request most recent head beb417b. Consider uploading reports for the commit beb417b to get more accurate results

@@             Coverage Diff              @@
##             master    #3857      +/-   ##
============================================
- Coverage     97.18%   97.15%   -0.03%     
+ Complexity     6432     6268     -164     
============================================
  Files           897      871      -26     
  Lines         18516    17990     -526     
  Branches       1216     1172      -44     
============================================
- Hits          17995    17479     -516     
+ Misses          412      404       -8     
+ Partials        109      107       -2     
Impacted Files Coverage Δ
...rg/vividus/ui/web/action/WebJavascriptActions.java 100.00% <ø> (ø)
...us/ui/web/listener/PerformanceMetricsListener.java 100.00% <ø> (ø)
...java/org/vividus/ui/web/action/WindowsActions.java 93.93% <94.44%> (ø)
...c/main/java/org/vividus/steps/WindowsStrategy.java 100.00% <100.00%> (ø)
.../main/java/org/vividus/steps/ui/web/PageSteps.java 98.93% <100.00%> (+0.11%) ⬆️
...java/org/vividus/steps/ui/web/SetContextSteps.java 100.00% <100.00%> (ø)
...ain/java/org/vividus/steps/ui/web/WindowSteps.java 100.00% <100.00%> (ø)
...n/java/org/vividus/ui/web/action/AlertActions.java 90.47% <100.00%> (-1.42%) ⬇️

... and 82 files with indirect coverage changes

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

@vkepin vkepin force-pushed the upd_webapp_tabs_steps branch from 1bb7371 to c3f7c0c Compare May 19, 2023 16:38
@@ -177,23 +177,29 @@ When I close browser

=== Wait for window and switch
Copy link
Contributor Author

Choose a reason for hiding this comment

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

update to tab

@vkepin vkepin force-pushed the upd_webapp_tabs_steps branch 3 times, most recently from 438c3c9 to 3fe992f Compare May 23, 2023 07:35
@vkepin vkepin changed the title Init commit Update syntax: 'tab' instead of 'window' May 25, 2023
Comment on lines 172 to 169
if (descriptiveSoftAssert.assertThat(String.format(NEW_TAB_FOUND_FORMAT, newTab),
newTab, not(equalTo(currentTab))))
Copy link
Collaborator

Choose a reason for hiding this comment

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

how does assertion message look like?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

New tab '{770e3411-5e19-4831-8f36-fc76e46a2807}' is found

Copy link
Member

Choose a reason for hiding this comment

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

quite informative :)

Copy link
Member

Choose a reason for hiding this comment

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

does iit make sense to put tab title as part of this msg?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as a result of descussion -> just remove tab id from the message


This step is used to open the provided URL in a new browser tab.
[NOTE]
The newly opened tab will be the active tab, and any subsequent steps will be carried out in this new tab.
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
The newly opened tab will be the active tab, and any subsequent steps will be carried out in this new tab.
The newly opened tab will be the active tab, and any subsequent steps will be executed on this new tab.

[source,gherkin]
----
When I switch to a new window
----

Copy link
Collaborator

Choose a reason for hiding this comment

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

it makes sense to keep it

Copy link
Collaborator

Choose a reason for hiding this comment

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

redundant changes

}

private void closeSmallerWindows(Set<String> windows)
// ??? Tabs or windows
Copy link
Collaborator

Choose a reason for hiding this comment

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

windows

@vkepin vkepin force-pushed the upd_webapp_tabs_steps branch 4 times, most recently from 482015c to ff9a97a Compare May 30, 2023 09:29
@vkepin vkepin force-pushed the upd_webapp_tabs_steps branch 2 times, most recently from da91add to 10adfc6 Compare June 5, 2023 16:50
@vkepin vkepin force-pushed the upd_webapp_tabs_steps branch 2 times, most recently from 871e145 to 516bb68 Compare June 9, 2023 08:46
@@ -696,6 +733,16 @@ Then text `Modal Frame Example` exists

Switch the focus of future browser commands to new tab.

This step gets the identifier of the currently active tab and then switches focus to the first available tab with a different identifier. For example, if tabs #1, #2, #3 are open and tab #2 is active, this method will switch focus to tab #3.
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 gets the identifier of the currently active tab and then switches focus to the first available tab with a different identifier. For example, if tabs #1, #2, #3 are open and tab #2 is active, this method will switch focus to tab #3.
This step gets the identifier of the currently active tab and then switches focus to the first available tab with a different identifier. For example, if tabs #1, #2, #3 are open and tab #2 is active, this step will switch focus to tab #3.


[source,gherkin]
----
When I open URL `$pageUrl` in new tab
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't it documented below?

* <ul>
* <li>Gets identifier of the currently active tab;
* <li>Switches focus to the first available tab with another identifier. So if currently there are 3 opened
* tabs #1, #2, #3 and tab #2 is active one, using this method will switch focus to the tab #3;
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
* tabs #1, #2, #3 and tab #2 is active one, using this method will switch focus to the tab #3;
* tabs #1, #2, #3 and tab #2 is active one, using this step will switch focus to the tab #3;

{
String currentTab = getWebDriver().getWindowHandle();
String newTab = windowsActions.switchToNewTab(currentTab);
if (descriptiveSoftAssert.assertThat("New tab is found", newTab, not(equalTo(currentTab))))
Copy link
Collaborator

Choose a reason for hiding this comment

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

haven't we agreed to simplify this assertion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if I understand correctly, we decided just to simplify the assertion message - remove tab id from the message

Copy link
Collaborator

Choose a reason for hiding this comment

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

it makes sense to replace assertThat with recordAssertion, since matcher not(equalTo(currentTab)) doesn't provide any value for users

@@ -212,7 +264,7 @@ public Boolean apply(WebDriver driver)
public String toString()
{
//TODO: change to comparisonRule.toString() once it will be safe
return String.format("switch to a window where title %s \"%s\"", comparisonRule.name(), title);
return String.format("switch to the tab where title %s \"%s\"", comparisonRule.name(), title);
Copy link
Collaborator

Choose a reason for hiding this comment

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

good time to switch to comparisonRule.toString()

@vkepin vkepin force-pushed the upd_webapp_tabs_steps branch from 516bb68 to 3b06421 Compare June 9, 2023 13:56
@valfirst valfirst force-pushed the upd_webapp_tabs_steps branch from 3b06421 to 7797299 Compare June 15, 2023 10:32
{
String currentTab = getWebDriver().getWindowHandle();
String newTab = windowsActions.switchToNewTab(currentTab);
if (descriptiveSoftAssert.assertThat("New tab is found", newTab, not(equalTo(currentTab))))
Copy link
Collaborator

Choose a reason for hiding this comment

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

it makes sense to replace assertThat with recordAssertion, since matcher not(equalTo(currentTab)) doesn't provide any value for users

softAssert.assertThat("Current window has been closed", driver.getWindowHandles(),
not(contains(currentWindow)));
softAssert.assertThat("Current tab has been closed", driver.getWindowHandles(),
not(contains(currentTab)));
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 about using recordAssertion instead of assertThat

Comment on lines 344 to 352
!-- Deprecated: 0.7.0, When I wait `%1$s` until tab with title that %2$s `%3$s` appears and switch to it
When I wait `<duration>` until tab with title that <comparisonRule> `<title>` appears and switch to it

Composite: When I close the current window
!-- Deprecated: 0.7.0, When I close current tab
When I close current tab

Composite: When I attempt to close current window with possibility to handle alert
!-- Deprecated: 0.7.0, When I attempt to close current tab with possibility to handle alert
Copy link
Collaborator

Choose a reason for hiding this comment

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

it was changed to upper case: !-- DEPRECATED:

@vkepin vkepin force-pushed the upd_webapp_tabs_steps branch 2 times, most recently from 7aa8bfe to e554e49 Compare June 27, 2023 09:55
@valfirst valfirst requested review from valfirst and uarlouski June 27, 2023 10:23
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.

Integration tests are failed

@vkepin vkepin force-pushed the upd_webapp_tabs_steps branch 4 times, most recently from 6c0c86b to 41290cf Compare June 28, 2023 16:21
@vkepin vkepin force-pushed the upd_webapp_tabs_steps branch from 41290cf to beb417b Compare June 28, 2023 16:34
@valfirst valfirst changed the title Update syntax: 'tab' instead of 'window' [plugin-web-app] Use tab instead of window in steps syntax Jun 28, 2023
@valfirst valfirst merged commit 6f8ee9c into vividus-framework:master Jun 28, 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