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: Add most common methods to the "SeleniumWebDriverHelper" #8746

Merged
merged 8 commits into from
Feb 14, 2018

Conversation

Ohrimenko1988
Copy link
Contributor

What does this PR do?

Add most common methods to the "SeleniumWebDriverHelper"

What issues does this PR fix or reference?

Issue: #8724

Release Notes

Docs PR

@Ohrimenko1988 Ohrimenko1988 added status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. kind/task Internal things, technical debt, and to-do tasks to be performed. team/che-qe labels Feb 13, 2018
* @param timeout waiting time in seconds
* @return found element
*/
public WebElement waitElementIsPresentInDom(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.

waitElementIsPresentInDom > 'waitElementIsPresented'

* @param elementLocator
* @return found element
*/
public WebElement waitElementIsPresentInDom(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.

* @param webElement
* @return element text by {@link WebElement#getText()}
*/
public String getFieldText(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.

waitElementText describes the propose of method much better, IMHO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry but I am not agree, this method waits for visibility of webelement and get text from it. It does not wait for a particular text.

Copy link
Contributor

@dmytro-ndp dmytro-ndp Feb 13, 2018

Choose a reason for hiding this comment

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

waitVisibilityAndGetText

* @param fieldLocator
* @return element text by {@link WebElement#getText()}
*/
public String getFieldText(By fieldLocator) {
Copy link
Contributor

Choose a reason for hiding this comment

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

* @param expectedValue
* @param timeout waiting time in seconds
*/
public void waitFieldValue(By fieldLocator, String expectedValue, int timeout) {
Copy link
Contributor

@dmytro-ndp dmytro-ndp Feb 13, 2018

Choose a reason for hiding this comment

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

Let's replace Field on Element to make method more general.

*
* @param fieldLocator
* @param expectedValue
*/
public void waitFieldValue(By fieldLocator, String expectedValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

* @param expectedValue
* @param timeout waiting time in seconds
*/
public void waitFieldValue(WebElement webElement, String expectedValue, 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.

* @param webElement
* @param expectedValue
*/
public void waitFieldValue(WebElement webElement, String expectedValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

* @param expectedText
* @param timeout waiting time in seconds
*/
public void waitFieldText(By fieldLocator, String expectedText, 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.

* @param fieldLocator
* @param expectedText
*/
public void waitFieldText(By fieldLocator, String expectedText) {
Copy link
Contributor

Choose a reason for hiding this comment

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

* @param webElement
* @param expectedText
*/
public void waitFieldText(WebElement webElement, String expectedText) {
Copy link
Contributor

Choose a reason for hiding this comment

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

*
* @param elementLocator
*/
public void moveToElementAndDoDoubleClick(By elementLocator) {
Copy link
Contributor

@dmytro-ndp dmytro-ndp Feb 13, 2018

Choose a reason for hiding this comment

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

moveToElementAndDoDoubleClick > moveCursorToElementAndDoubleClick


/**
* Moves cursor to {@link WebElement} with provided locator {@link By} and click twice on it by
* {@link org.openqa.selenium.interactions.Action} Used exactly {@link Actions#doubleClick()} and
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you, please, fix the java docs?

}

/**
* Moves cursor to provided {@link WebElement} and click twice on it by {@link
Copy link
Contributor

@dmytro-ndp dmytro-ndp Feb 13, 2018

Choose a reason for hiding this comment

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

*
* @param webElement
*/
public void moveToElementAndDoDoubleClick(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.

}

/**
* Moves cursor to {@link WebElement} with provided locator {@link By} and click once on it by
Copy link
Contributor

Choose a reason for hiding this comment

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

click > clicks

*
* @param elementLocator
*/
public void moveToElementAndClickOnIt(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.

moveToElementAndClickOnIt > moveCursorToElementAndClick

* WebElement#click()}
*
* @param webElement
*/
public void waitAndClickOnElement(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.

waitAndClickOnElement > waitAndClick

* @param webElement
* @param timeout waiting time in seconds
*/
public void waitAndClickOnElement(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.

* {@link WebElement#click()}
*
* @param elementLocator
*/
public void waitAndClickOnElement(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.

* @param elementLocator
* @param timeout waiting time in seconds
*/
public void waitAndClickOnElement(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.

*
* @param webElement
*/
public void moveToElementAndClickOnIt(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.

*
* @param elementLocator {@link By}
*/
public void moveToElemet(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.

moveToElemet > moveCursorToElement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hoverToElement

Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer moveCursorToElement so as it uses action#moveTo() method internally.

*
* @param webElement
*/
public void moveToElemet(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.

*
* @param locator
* @return state of element visibility
*/
public boolean elementIsVisible(By locator) {
Copy link
Contributor

Choose a reason for hiding this comment

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

elementIsVisible > isElementVisible

* @param webElement
* @return state of element visibility
*/
public boolean elementIsVisible(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.

}

/**
* Set text in provided field with checks
* Set text in provided field with checks which get text for compare by {@link
* WebElement#getAttribute(String)}
*
* @param webElement
* @param value
*/
public void setFieldValue(WebElement webElement, String value) {
Copy link
Contributor

@dmytro-ndp dmytro-ndp Feb 13, 2018

Choose a reason for hiding this comment

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

How about renaming setFieldValue > setElementValue?

}

/**
* Set text in provided field with checks
* Set text in provided field with checks which get text for compare by {@link
Copy link
Contributor

@dmytro-ndp dmytro-ndp Feb 13, 2018

Choose a reason for hiding this comment

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

Let's rewrite java docs to reflect steps which method is executing.

}

/**
* Set text in provided field with checks
* Set text in provided field with checks which get text for compare by {@link
Copy link
Contributor

@dmytro-ndp dmytro-ndp Feb 13, 2018

Choose a reason for hiding this comment

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

@@ -45,55 +45,59 @@ protected SeleniumWebDriverHelper(
}

/**
* Set text in provided field with checks
* Set text in provided field with checks which get text for compare by {@link
Copy link
Contributor

@dmytro-ndp dmytro-ndp Feb 13, 2018

Choose a reason for hiding this comment

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

Copy link
Contributor

@dmytro-ndp dmytro-ndp Feb 13, 2018

Choose a reason for hiding this comment

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

propose the next docs:
Ensures {@code element} has got {@code value} in next steps: ensures element is visible and has empty value, sets {@code value} by sending corresponding keys to {@code element}, and waits until element has got the {@code value}.

@@ -469,7 +473,7 @@ public boolean isElementVisible(By locator) {
* @param webElement
* @return state of element visibility
*/
public boolean isElementVisible(WebElement webElement) {
public boolean isVisible(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.

Looks like the method is waiting on element visibility with timeout ATTACHING_ELEM_TO_DOM_SEC.
Let's reflect it in method name and java docs.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about isVisibileDuringTimeout name?

* @return state of element visibility
*/
public boolean isElementVisible(By locator) {
public boolean isVisible(By elementLocator) {
Copy link
Contributor

@dmytro-ndp dmytro-ndp Feb 13, 2018

Choose a reason for hiding this comment

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

Looks like the method is waiting on element visibility with timeout ATTACHING_ELEM_TO_DOM_SEC.
Let's reflect it in method name and java docs.

@Ohrimenko1988 Ohrimenko1988 merged commit ca1a380 into master Feb 14, 2018
@Ohrimenko1988 Ohrimenko1988 deleted the selen-add-methods-SeleniumWebDriverHelper branch February 14, 2018 08:32
@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 14, 2018
@benoitf benoitf added this to the 6.1.0 milestone Feb 14, 2018
hkolvenbach pushed a commit to hkolvenbach/che that referenced this pull request Mar 2, 2018
…pdatemaster to master

updated to 6.1.0 stable, new keycloak theme

* commit 'e58465aaeea236ff051b8176af4581a443c0fd88': (115 commits)
  fixed fonts and added google fonts fallback
  added box shadow fix
  added lato regular as bold
  added lato light italic
  updated license header
  added Lato Light to fonts, removed CHE from login page
  ST-3764, ST-3613 Create keycloak docker image, and use the latest login theme
  Remove commented
  Updated version to 6.1.0 tag
  [maven-release-plugin] prepare release 6.1.0
  RELEASE: Update dependencies versions
  RELEASE: Update parent pom version
  RELEASE: Set tags in Dockerfiles
  CHE-8747. Fix displaying pull request panel (eclipse-che#8760)
  Add different style for focusable element (eclipse-che#8757)
  Selenium: Add most common methods to the "SeleniumWebDriverHelper" (eclipse-che#8746)
  Selenium: increase timeout to check that a menu item is enabled (eclipse-che#8755)
  Support enter press in refactoring rename form (eclipse-che#8754)
  Selenium: change a way for selecting an element from suggestions list (eclipse-che#8736)
  CHE-7278 Properly handle restarting the workspace (eclipse-che#8612)
  ...
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.

6 participants