Repository navigation
Allow keywords to use Web Elements in addition to Locator. - #356
Conversation
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.
There was a problem hiding this comment.
This should be 1.7 instead of 1.6.
There was a problem hiding this comment.
You are correct. How time flies!
There was a problem hiding this comment.
What needs to go here? We should probably flesh out these docs before merge.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
I'm okay with that, but we need to make a new issue for it so we don't forget.
|
When you get a chance, could you rebase? I fixed the Jenkins build failing. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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).
|
After you rebase, I'm ready to merge this in. |
There was a problem hiding this comment.
webelement and locator should be wrapped with backticks, not apostrophes.
|
Overall this looks good. I'm good for you to merge whenever you're ready. |
|
On 05/11/2015 10:49 AM, Zephraph wrote:
Yes, please merge in. |
|
It seems you need to rebase before I can do so. |
(Resolved) Conflicts: src/Selenium2Library/__init__.py
|
Merged with the minor documentation corrections added in. |
Allow keywords to use Web Elements in addition to Locator.
|
And that's a wrap! Great work! I want to add some integration tests before the 1.7 release, but we're super close! |
No description provided.