-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
…nd 'WebDriverWaitFactory' classes
ci-test |
ci-test build report: |
…work-projectexplorer
ci-test |
ci-test build report: |
…work they to enumerations
…work-projectexplorer
ci-test |
ci-test build report: |
…work-projectexplorer
this.seleniumWebDriverHelper = seleniumWebDriverHelper; | ||
loadPageTimeout = new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC); | ||
redrawUiElementsWait = new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC); | ||
this.helper = seleniumWebDriverHelper; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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. |
ci-test |
} | ||
|
||
/** select external maven Library relative module */ | ||
/** Select external maven Library relative module */ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link is outdated.
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. |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert.assertTrue(waitInvisibility)
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()
…ipse/che into selen-rework-projectexplorer
} | ||
|
||
/** Clicks on project explorer tab and waits its appearance. */ | ||
public void openPanel() { | ||
clickOnProjectExplorerTabInTheLeftPanel(); | ||
public void openAndWaitProjectExplorer() { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
ci-build |
ci-test |
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/4484/ |
ci-test build report: |
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