enter image description here

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.

1 Answer 1


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'))]")

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

  • I just click on the iframe by this xpath code. //*[contains(@id="container-")]
    – ChathuD
    Sep 2, 2020 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.