What do I do with ....WebElement(s)?

Asked by Jon Rosen

Okay, I got things coming back from my get_element method calls. The question now is, What do I do with them?

I tried inspecting them and there is essentially nothing visible there, just a _parent attribute (which is actually a python object for a Firefox window, I believe), and an _id. Nothing else. I tried dir() and inspect.getsource and got nothing but errors. I realize now that these may not be python objects, but what good is that?

I want to walk through the elements I retrieved in my get_elements_by_xpath method and retrieve all the text and some other stuff but this doesn't let me do that.

I looked at the examples and none of the examples show any use of the elements that come back from a get_elements method.

Help please? Thanks!

Question information

English Edit question
selenium-simple-test Edit question
No assignee Edit question
Solved by:
Corey Goldberg
Last query:
Last reply:
Revision history for this message
Best Corey Goldberg (coreygoldberg) said :

get_element returns a seleniun.webdriver WebElement instance.

see here for ducmentation:

However, SST is designed with functions for common interaction with elements, so you really don't need to know their own properties or methods often.

but, for example:
is the same as:

Revision history for this message
Jon Rosen (jfr) said :

Hi Corey,

Thanks for the update. I did some investigation on my own and figured out that I could pierce through the WebElement and use its own methods (but there are no attributes, that is apparently all completely opaqued). I also figured out that if I really wanted to, I can use sst's get_element_source to snag all the underlying html from an element and then do whatever I want with it (although that is usually a pretty daunting task).

Are you open to enhancements provided by users to add new methods to the existing functions?



Revision history for this message
Jon Rosen (jfr) said :

Thanks Corey Goldberg, that solved my question.

Revision history for this message
Corey Goldberg (coreygoldberg) said :

Hi Jon,

> Are you open to enhancements provided by
> users to add new methods to the existing functions?

yes, we are.
It's not a very active project at the moment, as some priorities have shifted for me. But I'm happy to do code reviews and merge enhancements or features (and there are a few other folks familiar with SST's internals to that can approve branches also).

Are you familiar with bzr and using Launchpad for development/review? If so, go ahead and push a branch and propose for merging whenever you want. I suggest doing small features in each branch, rather than dumping a whole set of things at once for review.

If you're not familiar with bzr/launchpad, let me know and I can walk you through it, or point you to some good docs.