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

Accept all text-like input fields in Textfield-related keywords #817

Merged
merged 9 commits into from
Jun 26, 2017

Conversation

leods92
Copy link
Contributor

@leods92 leods92 commented Jun 2, 2017

This fixes #546

@@ -192,6 +194,8 @@ def _element_matches(self, element, tag, constraints):
if not element.tag_name.lower() == tag:
return False
for name in constraints:
if type(constraints[name]) is list and element.get_attribute(name) not in constraints[name]:
return False
Copy link
Member

Choose a reason for hiding this comment

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

  • Why is this change needed?
  • Should use usinstance, not tyoe

Copy link
Contributor Author

@leods92 leods92 Jun 10, 2017

Choose a reason for hiding this comment

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

Why is this change needed?

Currently constraints only accept 1 value per element attribute and the change involves the creation of a list of values that should be considered acceptable.

Should use usinstance, not tyoe

Will do the change. Never coded in Python so I really don't know what's best. :) Thanks for the review! 👍

@pekkaklarck
Copy link
Member

I'm +1 for this enhancement but tests are needed and this should be mentioned in docs too.

@aaltat
Copy link
Contributor

aaltat commented Jun 4, 2017

And raise issue also from the problem, so that release notes are properly created.

@pekkaklarck
Copy link
Member

@aaltat There's already #546 about this.

@aaltat
Copy link
Contributor

aaltat commented Jun 5, 2017

Ah, I did not remember that one, thanks Pekka.

In any case, the changes needs to be tested. In in unit and/or acceptance level. Also the change breaks the existing unit test which is not acceptable.

For the code side, I do not have other comments than Pekka did made. Could you fix the testing side related problems and lets see how it continues from there.

@leods92
Copy link
Contributor Author

leods92 commented Jun 10, 2017

@aaltat

In any case, the changes needs to be tested. In in unit and/or acceptance level. Also the change breaks the existing unit test which is not acceptable.

Could you fix the testing side related problems and lets see how it continues from there.

For sure! When I opened the pull request I was busy at work. I was hoping somebody experienced would take it over. In any case, I have some time know and I'm gonna take the time to learn a bit about testing in Python. If I cannot successfully finish it, I'll let you guys know.

@leods92
Copy link
Contributor Author

leods92 commented Jun 10, 2017

@pekkaklarck

Could you please have a second look?
I tried to make tests diversified by testing 2 additional input types: email and url.
I believe they are the most used text-like input types after text.

I hope that's enough, if it's not, please let me know how I can improve. :)

Thanks!

@pekkaklarck
Copy link
Member

I'm on vacation without my laptop next week (and currently trying to get everything packed). I can take a quick look at the code now, but hopefully @aaltat has time for a full review.

else:
contraint = "@%s='%s'" % (name, value)
xpath_constraints.append(contraint)
return xpath_constraints
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be totally fine, but if there would be _get_xpath_constraint, looping could be handled by a list comprehension similarly as earlier:

xpath_constraints = [self._get_xpath_constraint(name, value)
                     for name, value in constraints.items()]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made this change too. It's much better. I was just afraid of creating a new method because all other methods in the file are relatively long. I really like having smaller and more methods. ^^

if isinstance(constraints[name], list):
if element.get_attribute(name) not in constraints[name]:
return False
elif not element.get_attribute(name) == constraints[name]:
Copy link
Member

Choose a reason for hiding this comment

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

Using != would be more clear than not and ==.

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 but I thought you Python guys did that (based on the line removed above). Change made! :)

@aaltat
Copy link
Contributor

aaltat commented Jun 12, 2017

I can take a look at this week.

@aaltat
Copy link
Contributor

aaltat commented Jun 19, 2017

And I was sick last week, I will try to find time this week.

@aaltat
Copy link
Contributor

aaltat commented Jun 20, 2017

By looking from mobile screen, this looks OK. I need to give second look from a bigger screen.

In mean while, could you rebase with master and create a PR which does not contain conflicts?

@aaltat
Copy link
Contributor

aaltat commented Jun 22, 2017

All looks OK to me. Would you mind sorting out the conflict and it can be merged to the master?

@leods92
Copy link
Contributor Author

leods92 commented Jun 24, 2017

@aaltat On it! Sorry it took me so long to reply. Weekend's here now! 💃

@leods92
Copy link
Contributor Author

leods92 commented Jun 24, 2017

@aaltat Rebased and Travis is green! ✅ 😄

@aaltat
Copy link
Contributor

aaltat commented Jun 25, 2017

No problem. I will try to take a look later and if all is well then merge to master.

@aaltat aaltat merged commit 9c017fb into robotframework:master Jun 26, 2017
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.

HTML5 specialized text fields not recognized as text fields
3 participants