Intro guide: using helium (python Selenium wrapper) with Robin

The incentive being this thread re clicking iframe elements by xpath, I searched for tools and found Helium, recently open-sourced by the author.

From the Github page:

iFrames: Unlike Selenium, Helium lets you interact with elements inside nested iFrames, without having to first “switch to” the iFrame.”

Just what I was looking for! This is for python, so you’ll need that installed to use Helium.

You can use jQuery-like syntax if you want, see the cheatsheet.

Here’s an HTML page you can save on your local file system to experiment with (I refer to it as ‘iframe.html’ for the rest of this guide):

<html>
<title>
My iFrame example
</title>
<body>
An iframe from an external source is below.
<hr>
<iframe name="Framename" src="http://www.allwebco-templates.com/support/" width="550" height="550" frameborder="0" scrolling="yes" style="width: 100%;"> </iframe> 
<hr>
Now try to click on elements inside the iframe from Robin.
</body>
</html>

First, some screenshots of the Python scripts (one for XPath, one for CSS).

For XPath (verbose xpath courtesy of this link, converted from easy CSS below:

Same script, but using CSS for selector:

iframes_css

And the Robin script that calls the Python. I’ve used ‘h12f.py’ for the XPath script, ‘h12g.py’ for the CSS script.

This demo loads the HTML page with an external iframe, clicks on an element within the iframe to load another frame, then grabs some text from an element.

Disclaimer: I have no relationship whatsoever to the webpage used for the external iframe, or to its authors.

Regards,
burque505

2 Likes