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

Selenium: Rework "ProjectExplorer" page object with "SeleniumWebDriverHelper" and "WebDriverWaitFactory" #8865

Merged
merged 24 commits into from
Feb 28, 2018

Conversation

Ohrimenko1988
Copy link
Contributor

@Ohrimenko1988 Ohrimenko1988 commented Feb 21, 2018

What does this PR do?

Rework "ProjectExplorer" page object with "SeleniumWebDriverHelper" and "WebDriverWaitFactory"

What issues does this PR fix or reference?

Issue: #8854
Issue: #8902

Release Notes

Docs PR

@Ohrimenko1988 Ohrimenko1988 added the kind/task Internal things, technical debt, and to-do tasks to be performed. label Feb 21, 2018
@Ohrimenko1988
Copy link
Contributor Author

ci-test

@codenvy-ci
Copy link

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:8865
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@Ohrimenko1988
Copy link
Contributor Author

ci-test

@codenvy-ci
Copy link

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:8865
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@Ohrimenko1988
Copy link
Contributor Author

ci-test

@codenvy-ci
Copy link

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:8865
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@benoitf benoitf added the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Feb 23, 2018
@Ohrimenko1988 Ohrimenko1988 changed the title [WIP] Selenium: Rework "ProjectExplorer" page object with "SeleniumWebDriverHelper" and "WebDriverWaitFactory" Selenium: Rework "ProjectExplorer" page object with "SeleniumWebDriverHelper" and "WebDriverWaitFactory" Feb 23, 2018
this.seleniumWebDriverHelper = seleniumWebDriverHelper;
loadPageTimeout = new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC);
redrawUiElementsWait = new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
this.helper = seleniumWebDriverHelper;
Copy link
Contributor

Choose a reason for hiding this comment

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

helper is too short name for the field, because it doesn't explain what kind of help it proposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you this is not very convenient but this is my point - this object uses almost in each project explorer's method, and that's why I did it shorter, and you just need one time used "F4" to see what it means and remember it for all cases.

Copy link
Contributor

@dmytro-ndp dmytro-ndp Feb 23, 2018

Choose a reason for hiding this comment

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

I understood why you had shorten the name. From the same reason it could be named as just "h" :-)
But it is not good idea to force readers to find the type of field to understand what it means.
Also, it allows to involve another type of helpers in future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will change it

Copy link
Contributor

@dmytro-ndp dmytro-ndp Feb 23, 2018

Choose a reason for hiding this comment

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

But we can get rid of SeleniumWebDriverHelper helper by moving its staff to the SeleniumWebDriver class itself. It also will make operation with page objects with different web driver instances more clear.

It also could fix issue #8902.

@dmytro-ndp
Copy link
Contributor

There are ~2000 changes in 128 files. Those are too many changes for the one pull request with a number of different refactoring operations. As a rule, each refactoring like extracting code into the SeleniumWebDriverHelper class, or encapsulating constants into the enumeration, ought to be rearranged by separate commit to make it possible to review correctness of each refactoring operation one by one.

@Ohrimenko1988
Copy link
Contributor Author

ci-test

}

/** select external maven Library relative module */
/** Select external maven Library relative module */
Copy link
Contributor

Choose a reason for hiding this comment

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

Select > Selects

*
* @param item item form {@code SubMenuNew}
* @param item item from {@link
Copy link
Contributor

Choose a reason for hiding this comment

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

Link is outdated.

@Ohrimenko1988
Copy link
Contributor Author

ci-test

* @param elementLocator
* @param timeout waiting time in seconds
* @return {@code true} - if not visible,
* <p>throws {@link org.openqa.selenium.TimeoutException} - if visible.
Copy link
Contributor

Choose a reason for hiding this comment

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

- if visible > - if visible after timeout

*
* @param elementLocator
* @param timeout waiting time in seconds
* @return {@code true} - if not visible,
Copy link
Contributor

Choose a reason for hiding this comment

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

returning boolean type is useless here because it can only return true, or throw timeout exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case all usages of this method need check with Assert.assertTrue()

* @return {@code true} - if not visible,
* <p>throws {@link org.openqa.selenium.TimeoutException} - if visible.
*/
public boolean waitInvisibility(By elementLocator, int timeout) {
Copy link
Contributor

Choose a reason for hiding this comment

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

returning boolean type is useless here because it can only return true, or throw timeout exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case all usages of this method need check with Assert.assertTrue()

* @return {@code true} - if not visible,
* <p>throws {@link org.openqa.selenium.TimeoutException} - if visible.
*/
public boolean waitInvisibility(By elementLocator) {
Copy link
Contributor

Choose a reason for hiding this comment

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

returning boolean type is useless here because it can only return true, or throw timeout exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case all usages of this method need check with Assert.assertTrue()

* @return {@code true} - if not visible,
* <p>throws {@link org.openqa.selenium.TimeoutException} - if visible.
*/
public boolean waitInvisibility(WebElement webElement, int timeout) {
Copy link
Contributor

Choose a reason for hiding this comment

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

returning boolean type is useless here because it can only return true, or throw timeout exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case all usages of this method need check with Assert.assertTrue()

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the benefit from Assert.assertTrue(true)? It checks nothing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Assert.assertTrue(waitInvisibility)

Copy link
Contributor

@dmytro-ndp dmytro-ndp Feb 27, 2018

Choose a reason for hiding this comment

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

Actually, we can simply replace Assert.assertTrue(waitInvisibility()) by waitInvisibility() without regression because in our case Assert.assertTrue(waitInvisibility()) <-> Assert.assertTrue(true).

* @return {@code true} - if not visible,
* <p>throws {@link org.openqa.selenium.TimeoutException} - if visible.
*/
public boolean waitInvisibility(WebElement webElement) {
Copy link
Contributor

Choose a reason for hiding this comment

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

returning boolean type is useless here because it can only return true, or throw timeout exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case all usages of this method need check with Assert.assertTrue()

}

/** Clicks on project explorer tab and waits its appearance. */
public void openPanel() {
clickOnProjectExplorerTabInTheLeftPanel();
public void openAndWaitProjectExplorer() {
Copy link
Contributor

Choose a reason for hiding this comment

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

openAndWait is enough because openAndWaitProjectExplorer duplicates class name ProjectExplorer.

*
* @param timeout user timeout
* @param timeout waiting timeout in seconds
*/
public void waitProjectExplorer(int timeout) {
Copy link
Contributor

@dmytro-ndp dmytro-ndp Feb 27, 2018

Choose a reason for hiding this comment

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

Let's name it just wait, because waitProjectExplorer duplicates class name ProjectExplorer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, wait() can't be used indeed. waitAppearance() is possible variant instead, IMHO

@@ -156,45 +156,37 @@ public WebElement waitVisibility(WebElement webElement) {
*
* @param elementLocator
* @param timeout waiting time in seconds
* @return {@code true} - if not visible,
* <p>throws {@link org.openqa.selenium.TimeoutException} - if visible after timeout.
Copy link
Contributor

Choose a reason for hiding this comment

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

@throws {@link org.openqa.selenium.TimeoutException} - if is visible during timeout. could be still useful for reader.

@dmytro-ndp
Copy link
Contributor

ci-build

@dmytro-ndp
Copy link
Contributor

ci-test

@codenvy-ci
Copy link

@codenvy-ci
Copy link

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:8865
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@Ohrimenko1988 Ohrimenko1988 merged commit 1475ff9 into master Feb 28, 2018
@Ohrimenko1988 Ohrimenko1988 deleted the selen-rework-projectexplorer branch February 28, 2018 07:48
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Feb 28, 2018
@benoitf benoitf added this to the 6.2.0 milestone Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/task Internal things, technical debt, and to-do tasks to be performed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants