Error: Cannot Find Element After Several Sucessfull Loops

The purpose of my script is to create a member account. To do this I click on a link which opens a module (iframe) where I can setup the member using drop down selections and text fields.

The script works, but after several loops an error occurs (Element Not Found) on one command where I ask it to click on the “MemberSubType” drop down and select “Individual”. I’ve used a couple tools like the Katalon Web Spy and SelectorsHub to make sure I use the correct xpath, but I don’t think KR is looking in the correct iframe even though I use the SelectFrame(Index=0). I only have the error when it is selecting the first element in the iframe. There are no errors when it selects elements in other drop downs.

Any thoughts?"")
Thread.sleep(1000);"link=New Member")
/* selenium.Click("xpath=//select[@id='ctl00_MainContent_lstMemberSubType']") */
/* selenium.Click("xpath=//option[normalize-space()='Individual']") */"link=Individual")

Screen Shot 2022-09-15 at 1.44.14 PM

Your screenshot:

This code stops for 1000 mili-seconds after it open the target URL and before it clicks something. What do you think will happen if the page took longer than 1000 milli-seconds to load in browser? — The click operation will fail because it can not find the element to click.

The “pause 1000” statement is not good enough. You should not use PAUSE command to make sure a HTML element to be present.

Do you understand this?

The purpose of the pause was to give the window time to open.

Still an error with the removal of that line.

It’s not to get rid of your delay, but to insert a delay that is associated with the time it takes for your element to exist on the page, however variable the amount of time that would be. Your delay of 1000 ms worked for some of your test, but then it “stopped” working. So, instead, can you insert a delay until the element is always visible. Or, have both delays.

New Selenium IDE – Using ‘wait for element visible’ command - QAFox

waitForVisible (and waitForNOTVisible) - Selenium IDE Commands Tutorial (

Can I use “xpath=//select[@id='ctl00_MainContent_lstMemberSubType” as the target?"")
Thread.sleep(2000);"link=New Member")
for (int second = 0;; second++){
    if (second >= 60) fail("timeout")
        if (selenium.isElementPresent("xpath=//select[@id='ctl00_MainContent_lstMemberSubType']")) break
    } catch (Exception e){
/* selenium.Click("xpath=//select[@id='ctl00_MainContent_lstMemberSubType']") */
/* selenium.Click("xpath=//option[normalize-space()='Individual']") */"link=Individual")"xpath=//form[@id='aspnetForm']/div[4]/div/table/tbody/tr[2]/td[2]/div/button")"link=Athlete")

Why don’t you just try it and see?

It is only you who can find the answer. Others can not try it on their own machines. They have no access to your Application Under Test.


You ignored the built-in “waitForVisible” command that @grylion54 suggested. It seems you stick to pause XXXX command instead.

Why? Do you want to re-invent a “waitFor” command for yourself?

Thanks for the response.

I tried the waitForVisable instead of the pause which worked for a few loops, but still fails eventually. I think the issue is related to a new window (iframe) opening, maybe the selectFrame command occurs before the new window is completely loaded so it’s not able to find the element in the waitForVisable command?


Any thoughts?

Where do you find the element of your interest ---- in the base window, or in the newly opened window?

Your code looks like:

This indicates that you are trying to find the element in the base window. But is it really the case? If the element is in the new window, you need to select the new frame.

How to? ---- I don’t see. You haven’t showed the HTML source to us, so others can not see how to modify your code appropriately.

I am looking for the element in the newly opened window.

In reference to the video at the begging of the thread, you can see that after I click on the “New Member” button a new window opens and I was under the impression that it’s base index number was 0 because that is what KR provided when I selected the new window during recording and it works. I’ve tried “relative=top”to select the top frame, as well as “index=1” to select the second frame, but those fail.

HTLM Source here

Possibly you have 2 problems here.

  1. index=0 is pointing the base window, not the newly opened window.

  2. css=button[title='- MemberSubType --'] is wrong.

You need to solve both.

Please try to find the right code for yourself.

We’ve gone off topic.

The script works and loops numerous times. I just don’t under stand why occasionally it fails at the same place.