Skip to content

Allow keywords to use Web Elements in addition to Locator. - #356

Merged
just-be-dev merged 23 commits into
robotframework:masterfrom
emanlove:webdriver-element
May 19, 2015
Merged

just-be-dev merged 23 commits into
robotframework:masterfrom
emanlove:webdriver-element

Conversation

@emanlove

@emanlove emanlove commented Feb 2, 2015

Copy link
Copy Markdown
Member

No description provided.

emanlove added 20 commits July 26, 2014 21:16
In some cases I want to be able to store the element itself and then act upon
the element as compared to passing a locator each time and re-finding the
element. At this point I am implementing this by checking the locator argument
within keywords/_elements.py. This could possibly fit into the element finder
code but this approach seems more desirable in that it is the point where the
"locator" is passed in and an element is returned. Now instead it checks to
see if the "locator" is a string and if so tries to find the element. And if
it is an element is goes ahead and passes it through. Testing is needed to verify this doesn't break anything in addition to verify no other keywords would have issues if passed a WebDriver Element instead of a locator
string.
Moved the checks for required and first_only under check for locator as if
"locator" is a WebElement is found and singular. Pass WebElement "locator"
into elements varaiable. ToDo: Still need to handle list of WebElements.
Removing the placeholder for the (proposed) singular 'Get WebElement' keyword.
In discussions with Kevin and Pekka it was suggested that the having only
'Get WebElements' (multiple) would provide both cases and help keep number
of keywords to a reasonible number. In addition, it has been suggested to
add either a index or firt-only flag to 'Get WebElements' (to come in
another commit).
In some cases I want to be able to store the element itself and then act upon
the element as compared to passing a locator each time and re-finding the
element. At this point I am implementing this by checking the locator argument
within keywords/_elements.py. This could possibly fit into the element finder
code but this approach seems more desirable in that it is the point where the
"locator" is passed in and an element is returned. Now instead it checks to
see if the "locator" is a string and if so tries to find the element. And if
it is an element is goes ahead and passes it through. Testing is needed to verify this doesn't break anything in addition to verify no other keywords would have issues if passed a WebDriver Element instead of a locator
string.
Moved the checks for required and first_only under check for locator as if
"locator" is a WebElement is found and singular. Pass WebElement "locator"
into elements varaiable. ToDo: Still need to handle list of WebElements.
Removing the placeholder for the (proposed) singular 'Get WebElement' keyword.
In discussions with Kevin and Pekka it was suggested that the having only
'Get WebElements' (multiple) would provide both cases and help keep number
of keywords to a reasonible number. In addition, it has been suggested to
add either a index or firt-only flag to 'Get WebElements' (to come in
another commit).
…k-selenium2library into webdriver-element

Conflicts:
	src/Selenium2Library/__init__.py
This, yet to be written, section will be added later. Going to remove it for
now from the changes made for using web elements as locators and will make a
seperate commit/pull request for it.
Comment thread src/Selenium2Library/__init__.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be 1.7 instead of 1.6.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You are correct. How time flies!

Comment thread src/Selenium2Library/__init__.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What needs to go here? We should probably flesh out these docs before merge.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thought I had pulled that out. It was a placeholder for talking about stale elements as recommended above by @ombre42. Since it was taking too long to compose the doc I was going to add it later...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm okay with that, but we need to make a new issue for it so we don't forget.

@just-be-dev

Copy link
Copy Markdown
Contributor

When you get a chance, could you rebase? I fixed the Jenkins build failing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of Get WebElements, how would you feel about just Get Elements . Also, would it be useful to have a Get Element that only gets a single element, or would that be unnecessary/confusing?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@ombre42 and I discussed this over on #315. 'Get Elements' was my original name but changed it because it conflicted with the XML Library's keyword of the same name. So we settled on Get WebElements. I also had a 'Get WebElement' (singular) keyword in there but removed it for some reason. I was doing some recent testing with this and saw a possible need for getting a single web element.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about Find Element and Find Elements then? It's not necessarily as clear, but that matches up with the selenium API. (I'm not really necessarily opposed to Get WebElements though).

@just-be-dev just-be-dev added this to the 1.7 milestone May 2, 2015
@just-be-dev

Copy link
Copy Markdown
Contributor

After you rebase, I'm ready to merge this in.

Comment thread src/Selenium2Library/__init__.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

webelement and locator should be wrapped with backticks, not apostrophes.

@just-be-dev

Copy link
Copy Markdown
Contributor

Overall this looks good. I'm good for you to merge whenever you're ready.

@emanlove

Copy link
Copy Markdown
Member Author

On 05/11/2015 10:49 AM, Zephraph wrote:

@emanlove https://github.com/emanlove, would you be okay if I went
ahead and merged this? The documentation nitpicks will be fixed on the
next update anyway, and I can add a PR to do the |Get WebElement| Keyword.

—
Reply to this email directly or view it on GitHub
#356 (comment).

Yes, please merge in.

@just-be-dev

Copy link
Copy Markdown
Contributor

It seems you need to rebase before I can do so.

@emanlove

Copy link
Copy Markdown
Member Author

Merged with the minor documentation corrections added in.

just-be-dev added a commit that referenced this pull request May 19, 2015
Allow keywords to use Web Elements in addition to Locator.
@just-be-dev
just-be-dev merged commit 0c25caa into robotframework:master May 19, 2015
@just-be-dev

Copy link
Copy Markdown
Contributor

And that's a wrap! Great work! I want to add some integration tests before the 1.7 release, but we're super close!

@emanlove
emanlove deleted the webdriver-element branch December 19, 2023 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants