Lemonce Editor is a professional web application testing tool that offers a convenient way to handle iframes in any automated web test project. You never need to write additional codes or testing scripts for handling iframes, no matter your test case need identify nested ifrmaes or switch over the elements in iframes. Compared to Selenium that requires much coding work and tedious steps, Lemonce Editor is the best web testing tool to handle iframes in web test automation.


Why and how to handle iframes in automated web test with Lemonce Editor?


As a better alternative to Selenium, Lemonce Editor has some outstanding advantages in terms of Iframe testing:

  • Record Iframe related user actions automatically without extra coding
  • Directly penetrate elements to exactly locate iframes with its unique iframe penetration selector. And the “Inspect Element” button built in the test case editor can facilitate the process of editing test case. (When handling Iframes using WebDriver, you need switch in and out the iframe frequently.)
  • No OS and browser compatibility issues when executing test case consisting iframe selector (When handling iframes using selenium webdriver, you need install browser add-ons and extensions and take care of OS and browse compatibility problems)

Lemonce editor is a great iframe testing tool that is much better than Selenium. Here are more details and examples about how to handle iframe in web testing projects with Lemonce Editor.

1.Recoding Iframe for automation web test

When you record iframe with Lemonce Editor, you will not need to know you are recording user actions on iframes. The iframe recording process is the same as other action recoding on other web objects or elements in a web app test. Definitely, the iframe recoding can be also played back reliably. The automatic recording process will generate testing codes properly, like these:

The yellow highlighted codes are the mark of iframe path which is automatically generated by Lemonce recording process. Lemonce’s unique simple programming language, LemonCase, can originally support iframe penetration selector (the red highlighted mark“<”). With this approach, no matter how complex the iframe path is, testing professionals can precisely capture the path of iframes. This will bring great testing experience to any web application tester. You will never encounter a problem like that is unable to locate iframe in selenium webdriver.

2.Iframe Selector and “Inspect Element” Button

When editing a test case containing iframe element, there is a “Inspect Element” button in test code editor. The button is used for capturing element path on the current web page. This function can originally support frame penetration on webpage. Here is a screenshot of an example how this testing tool can penetrate iframe to select elements inside the frame.

Through selecting a element temporarily to achieve direct penetration into iframe, the path captured from element selection will be: ‘#mainFrame < #QMEditorArea > table:nth-child(2) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(1) > iframe:nth-child(1) < body’;

The iframe penetration selector can bring many benefits. The obviously one is, unlike Selenium, this iframe handling method doesn’t require switching to iframe in and out. It is quite easy to identify and locate iframe accurately. Another benefit is to lower the learning cost for a testing team. The element selector will work in the same way for any element no matter it is an iframe or not. So, testers don’t need learn something special or new to write extra scripts to handle element in iframes.

3.Test Execution Engine and Driver for Iframe Testing Support

Lemonce execution engine, LCVM (Lemonce Virtual Machine), can work seamlessly with LCDriver, (Lemonce Driver), and support smooth test execution of iframe elements on any browser without adjusting testing codes. This selenium alternative tool will greatly increase the convenience of iframe testing. Because it is not sensitive to OS and browser, you don’t need to consider compatibility solutions. This is a great advantage over Selenium Web Driver. To handle iframe testing, LCDriver can support direct cross-domain testing for both third-party web contents and local components. It is somewhat similar to CORS (Cross-Origin Resource Sharing), which has cross-domain access controls to manipulate web contents across domain-boundaries.

Many web testing professionals often encounter problems on working with Iframes. They usually search on github or Google to get some clues on how to handle iframes in selenium webdriver. Unfortunately, they will finally feel difficult to find great solutions or easy approaches to implement web tests consisting multiple iframes and user actions on the iframes. Actually, many selenium issues related to handling iframes in selenium webdriver on github are still unclosed, or those open source selenium solutions cannot work properly.


What are the difficulties or challenges you faced in selenium ?


The followings will explain why there is no convenient and easy approach to handle iframes in selenium web driver.

First, it is difficult to locate and recognize elements inside an iframe using selenium webdriver.

To identify iframe and find elements inside, a human can easily inspect the web page by viewing page source codes manually. But it is impossible to locate the element by clicking iframe directly through xpath since it is a special web component - iframe. You must have a test script specifically to switch to the frame and then to click it using xpath. That is, if you need to switch to other frames, you have to switch back to the main frame( default frame ), or move back to the parent frame. Even though it is quite complicated to handle iframes using selenium webdriver and it requires huge coding workload, some web app testers and programmers have to spend much time and effort to write scripts for this because many other web application testing tools don’t provide a solution for handling iframes in test automation.

Lemonce Editor obviously can overcome this hurdle with its iframe penetration selector that can easily locate and recognize iframe and identify the elements in side any frame. Testing professionals will not need figure out how to find element in iframe using selenium webdriver anymore.

Second, Selenium recorder is just a Firefox add-on, Selenium IDE, which only performs limited recording and playback functions for web app tests, and cannot work with other browsers, like Chrome, IE, etc. In addition, when handling iframes, Selenium IDE can record and play back tests properly, but it cannot export testing scripts correctly. That is, Selenium IDE recorder is unable to automatically generate testing codes, and you have to manually edit and modify codes!

Here is a example of test case for pages consisting frames recorded and created by Selenium IDE: (The test codes cannot be generated properly.)

Lemonce LCDriver can work much better than Selenium Web Driver, and set Chromium as browser core, so Lemonce recorder can work well on Chrome and is friendly with other browsers. In addition to recoding and playing back test cases reliably and accurately , Lemonce recorder can automatically generate codes properly when recoding iframe related web actions.

public void test331IframeTest() throws Exception { 
    driver.get(baseUrl + "/tiy/t.asp?f=html_iframe_src"); 
    // ERROR: Caught exception [ERROR: Unsupported command [selectFrame|i|]]
    driver.findElement(By.linkText("HTML5")).click(); 
    driver.findElement(By.linkText("HTML5 Intro")).click(); 
    driver.findElement(By.linkText("HTML5 Video")).click();
    driver.findElement(By.cssSelector("li.next > a[title=\"HTML5 Video + DOM\"]")).click();
    driver.findElement(By.cssSelector("li.next > a[title=\"HTML5 Audio\"]")).click();
    // ERROR: Caught exception [ERROR: Unsupported command [selectWindow |null|]]
    driver.findElement(By.id("TestCode")).clear();
}

Third, it is very difficult to identify and handle nested frames in selenium webdriver. As we know, there are still many obsolete and legacy web application systems running in the IT world, which were developed with iframe techniques in the past period when there is no advanced tech method, like websocket, ajax , to process asynchronization request on web. There will be many frames in a web page, including nested frames(frames embedded inside frames). There is no simple and reliable solution to solve the issues to handle nested iframes using webdriver.

Usually, to switch over elements in iframes using WebDriver, you need write testing scripts to achieve this by name or ID, web element, or by index. It is tedious enough to get a selenium solution in these ways.

However, in some scenarios, this selenium method cannot switch using ID,name, or web element because the information is unknown, including: which iframe required elements are being loaded , the index of the frame, etc. How to switch over the frame using webdriver in these cases? You have to write specific scripts for finding the index of the frame by which the elements are being loaded, and then switch to the iframe through the index found. This approach of frame handling will let you at least find out a solution in Selenium without id.

Obviously, the above steps and approaches are complicated enough. If you use selenium webdrive to handle multiple nested frames, then any testing expert will feel painful. If a website has multiple frames on a single webpage, and a frame also has inner frames, such as, a frame inside a frame, you need do extra coding for:

  • Switch to the outer frame by either ID or Index of the iframe
  • Find and calculate the total quantity of iframes inside the outer frame
  • Switch to the inner frame by name, id, index or web element
  • Take care of the order of switching over the inner frame and outer frame

The above steps or ways will cost a test professional much time to write scripts. In fact, it is not easy at all for a beginner to write selenium codes to even identify or get current frame or move back to parent frame (or relative frame). Unlike a easier way on how to switch to form in selenium webdriver, the method to switch over frames is pretty complicated in selenium test execution.

Lemonce Editor doesn’t have such selenium problems and issues when handling nested iframes. No matter how many multiple frames are embedded one by one, or how complicated a path of the frame is, Leomonce can easily achieve accurate element identification and selection by penetrating multiple iframes, working in the same way to handle other web elements on a web page without iframes.


In addition to the above the technical challenges with selenium when handling frames, actually there are other issues like the problem in selenium wait for iframe to load, Lemonce recorder works better than Selenium IDE recorder. It has a function in test recoding that offers intelligent waiting for iframe loading or any element operations inside the frame.

Even today, Iframes are still working as key elements on many websites or web app platforms, including advertisement frames or even some common web components, such as a calendar. And some web application development tools or platforms, like JEECG, can allow users to quickly and easily build multiple complex iframes on web site. If you are still using Selenium 2.0, or you will upgrade your test team to use Selenium 3.0 in the future, you will always be unable to handle iframe testing efficiently. As you know, Selenium is an Open Source project in which many teams work from many different prospects and dimensions, it is almost impossible to solve some complicated testing problems like issues for iframe testing, neither build a perfect iframe testing framework. Many experienced testing teams realize Selenium limitations on automated web test. No matter how hard Selenium programmers do coding with python, c#, or Java, there is no perfect solution to solve iframe issues in Selenium. It will not be strange for a tester to get error like “selenium iframe element not found”。 In fact, it will also take time for a testing programmer to write testing codes to deal with an simple element, such as, how to handle form in selenium webdriver.

Therefore, you don’t need to waste time anymore to search “selenium iframe testing” or “iframe selenium” on github or other internet sources to find a solution on how to handle iframes using selenium webdriver. Even you can find a selenium iframe example (coding template) on github, it usually will cost you much time to learn and modify those testing example codes. As a smart web application testing team member, you just need find a professional automated UI testing tool that can perform tests on iframes easily with minimum coding work. Lemonce Editor is such a great Iframe testing tool, which can help you complete any automation testing projects smoothly and properly, and resolve all the difficulties or challenges you faced in selenium and other testing tools in the market.

In fact, in addition to iframe testing, Lemonce has more advantages than Selenium in the area of web app testing. For example, Lemonce has more powerful features to accurately identify and locate web elements easily. (see more about web element location features in Compare Lemonce and Selenium Selectors) Please also click here to view the comparisons between Lemonce Editor and Selenium.