Issue with switching / clicking an iFrame jmeter selenium

WePython 1 Months+

As on the image I have to click on the highlighted iFrame and I'm on Jmeter Web Driver Sampler. The issue is the bottom part of the iFrame id will get change time to time. So can't exactly identify it using ID.

If this is with C# then I can get a list with all tag names == iFrame and click on the selected iFrame.

But with Jmeter Web Driver Sampler I'm not sure how to do something like this.

-----------------Answer-----------------

I can see 2 iframes in your picture, one is visible and another one is not visible (the highlighted one).

So you need to:

  1. Locate the iframe element which display property is not none using normal WebDriver.findElement() function which returns a WebElement
  2. Switch to it using the WebElement from the previous step

Example code:

var iframe = WDS.browser.findElement(org.openqa.selenium.By.xpath("//iframe[not(contains(@style, 'display: none'))]")
WDS.browser.switchTo().frame(iframe)

More information: The WebDriver Sampler: Your Top 10 Questions Answered


Previous : Test Automation tool for Data Analytics Software
Next : Tuning .net core 3.1 application load testing using Jmeter on linux