Current time: 06-24-2017, 03:18 AM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot click a link inside a frame
03-17-2017, 08:50 AM (This post was last modified: 03-17-2017 08:52 AM by hali.)
Post: #1
Cannot click a link inside a frame
I am trying to test an app we develop via webpagetest. It is not publicly available, so I cannot provide access, but here's some details:
1) the page has a set of iFrames on it, it is organised through yui framework (I'm not a dev, so that's as much as I know)
2) the link I want to click is inside one of the iframes with a code like below (I removed all other elements). When I click on that link manually, changes occure in another frame, and even if I open menu frame in a separate tab, all of the frames still seem to be connected somehow (I guess, through yui).
3) I am trying to click entry-0-1 link, and I have tried all I could think of: click, clickAndWait, sendClickAndWait, exec/execAndWait... I also tried using sleep before trying to click a link, as advised for a similar problem in MS edge webdriver. I tried different browsers. There are no error messages anywhere, but no activity either, test just waits for "up to 420 seconds" to finish.

Any idea what the problem might be? Did anyone ever encounter smth like this? Hard to believe I'm the first one...
Code:
<body>
    <div id="menu-container">
        <div id="menus" role="tabpanel">                            
            <a id="Link0" menuindex="0" class="menu-name"  href="#" onclick="toggleMenu( 0 );return false" role="tab" aria-expanded="false">
                    <span class="menu-name-icon fa fa-caret-right"></span><span class="menu-item-content">Menu Name</span>
            </a>
            <div class="menu" role="tabpanel">
                <ul id="Menu0" class="menu-entries invisible-links">
                    <li>
                        <a id="entry-0-1" tabindex="-1" class="menu-entry" href="#" onclick="openApplication('Patient Search and Demographics', 'Patient Search', this);return false">
                            <span class="menu-item-content">Search Button</span>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</body>
Find all posts by this user
Quote this message in a reply
03-17-2017, 05:48 PM
Post: #2
RE: Cannot click a link inside a frame
If the iframe is in the same domain you can find the elements in the iframe document like this:
Code:
document.querySelector("iframe[id=FRAME-ID]").contentWindow.document.querySelector("#entry-0-1")
They won't be discoverable in the top document.

Try to do it in the javascript console of your browser, locally. If it works there, it should work in WebPagetest. Be careful not to be mislead by Chrome automatically switching to the iframe when you select an element with the Inspector. The current iframe is displayed in a dropdown at the top of the javascript console.

Some browsers (Firefox, Edge, IE) allow you to navigate accross frames using the cd() command. Then you can just find it as if it is the main document - $("#entry-0-1"). Chrome doesn't have this.

If the iframe source is a different domain, you won't be able to access it via javascript or jQuery in any browser due to same origin policy. I don't know if there is a way to do it in WebPagetest.

If it still doesn't work, you can post here the script you are trying to run.
Find all posts by this user
Quote this message in a reply
03-18-2017, 11:30 AM
Post: #3
RE: Cannot click a link inside a frame
Thank you so much @sertovs, it worked like magic! For some reason I didn't even think that you can use whatever javascript you want in the exec/execAndWait commands, silly me. :-)
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)