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

Fix for issue #65 #66

Merged
merged 4 commits into from
Aug 10, 2014
Merged

Fix for issue #65 #66

merged 4 commits into from
Aug 10, 2014

Conversation

alkedr
Copy link
Contributor

@alkedr alkedr commented Jul 23, 2014

Related to #65

// element must be <textarea> or <input> with type text, password, email etc
// See https://github.com/yandex-qatools/htmlelements/issues/65
private static String getClearTextInputElementCharSequence(WebElement element) {
return StringUtils.repeat(Keys.DELETE.toString() + Keys.BACK_SPACE, element.getText().length());
Copy link
Contributor

Choose a reason for hiding this comment

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

Why you call .toString() method?

I believe if we call it, then it needs to be done for BACK_SPACE key as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't compile without .toString() beause Keys is an enum.
Keys.BACK_SPACE is implicitly converted to string.
http://stackoverflow.com/questions/328661/explicit-vs-implicit-call-of-tostring

Copy link
Contributor

Choose a reason for hiding this comment

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

for some fields element.getText() will return empty string when element.getAttribute("value") will return not empty result

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 that case we need to replace element.getText().length() with Math.max(element.getText().length(), element.getAttribute("value")).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah. I finally see, why there is a problem. In the original code, that was used to create that PR: https://github.com/minkphp/MinkSelenium2Driver/blob/master/src/Selenium2Driver.php#L659-L662 we're:

  1. operation only on input and textarea elements
  2. always taking the value attribute value (the attribute method in selenium in fact looks in JS .value property on DOM node and gets it's value, rather then HTML attribute value, that doesn't exist on textarea)

And using getText here is a huge mistake, because https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/text it returns visible text on element (e.g. div and such), but not inputs :)

@aik099
Copy link
Contributor

aik099 commented Jul 23, 2014

Issue numbers mentioned in PR title doesn't auto-link PR with corresponding issue.

Usually I put this into description:

Related to #65

@alkedr
Copy link
Contributor Author

alkedr commented Aug 1, 2014

Will this pull request be merged?

@artkoshelev
Copy link
Contributor

Looks good, can you add some tests to document new behavior?

artkoshelev added a commit that referenced this pull request Aug 10, 2014
@artkoshelev artkoshelev merged commit 08c2580 into yandex-qatools:master Aug 10, 2014
@artkoshelev
Copy link
Contributor

well done!

@aik099
Copy link
Contributor

aik099 commented Mar 26, 2015

Aren't there any universal method for getting element value?

@alkedr
Copy link
Contributor Author

alkedr commented Mar 26, 2015

I thought element.getText() was universal method for getting element value.

}
}

// Returns sequence of backspaces and deletes that will clear element
Copy link
Contributor

Choose a reason for hiding this comment

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

for future prs :) - use javadoc style comments on methods - \** */

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.

6 participants