0

Simply put, for some reason the site I'm working with has set up this section of inputs as follows:

<iframe title="parentIframe">
#document (https://www.website.com)
    <!DOCTYPE html>
    <html lang="en">
        <head></head>
        <body>
            <div id="root">
                <div id="firstDiv">
                    ... //the iframes are within an arbitrary number of divs
                    <iframe title="firstChildIframe">
                        #document (https://www.website.com/subsite1)
                            <!DOCTYPE html>
                            <html lang="en">
                                <head></head>
                                <body>
                                    <input name="firstInput" />
                                </body>
                            </html>
                    </iframe>
                    ...
                </div>
                <div id="secondDiv">
                    ...
                    <iframe title="secondChildIframe">
                        #document (https://www.website.com/subsite2)
                            <!DOCTYPE html>
                            <html lang="en">
                                <head></head>
                                <body>
                                    <input name="secondInput" />
                                </body>
                            </html>
                    </iframe>
                    ...
                </div>
                <div id="thirdDiv">
                    ...
                    <iframe title="thirdChildIframe">
                        #document (https://www.website.com/subsite3)
                            <!DOCTYPE html>
                            <html lang="en">
                                <head></head>
                                <body>
                                    <input name="thirdInput" />
                                </body>
                            </html>
                    </iframe>
                    ...
                </div>
            </div>
        </body>
    </html>
</iframe>

For automated testing, we are using some fork of webdriver with nodeJS, and I have hit a wall.

I have tried using this.focusFrame() and browser.switchToFrame() with //iframe[@title="____ChildIframe"] and iframe[title="____ChildIframe"], both of which work in the Inspect/Elements search bar of Chrome, but I just can't seem to find a way to make this work.

Once inside the parent iframe using this.focusFrame('//iframe[@title="parentIframe"]'), the runner stays frozen and doesn't do anything, probably looking for the first iframe child on a loop and never finding it. I have no idea what I'm missing. Perhaps, since the iFrame contents are being loaded in a different site or are part of a different HTML, the runner doesn't know what to do? What am I missing?

Thanks for your help!

2
  • Your use of the title attr is incorrect. It is for screen readers and should match the title element in the iframe to aid navigation for blind users. Commented Oct 28, 2024 at 18:51
  • @DavidBradshaw due to the sensitive nature of the project, the other more helpful attributes are the kind to change with every session or even refresh. They do have some strings that persist on the name and id attr, but after swapping my locators to something like //iframe[contains(@id, '~FirstIframe~')], project still hangs after the first focus for the parent frame. Commented Oct 28, 2024 at 21:26

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.