1

The problem:

  • I have several processes that need to run in one iFrame, and I have another process that needs to run concurrent to the others but in a different iFrame. If I use driver.switch_to_frame("frame1") then the processes in frame2 will crash.

Attempted solution:

  • I have processes in frame1 start the process in frame2 and wait for it to finish before continuing. I don't like this because the processes are time sensitive and this slows them down considerably. This also isn't easily scalable to >2 iFrames.

What I'm trying to ask is, is there an elegant way for the driver to focus on multiple iFrames at the same time? I'm using Python, but if you have a solution in another language I would be happy to learn it.

Jake
  • 228
  • 1
  • 2
  • 14
  • 1
    I don't think there is. You'd have to `switch_to_default_content()`, then to the frame you want to monitor, wait for the condition to occur, then switch back to the other frame. My only suggestion to work around this would be to use javascript executor to monitor the page instead. – Richard Feb 20 '14 at 17:53
  • Wow, I'm slightly embarrassed to say I wasn't aware I could execute JavaScript like that. I think that's an even better solution than what I was hoping for, thanks a ton! (Side-note: I'm leaving the question open for now but I'll remember to mark it as solved if I can get this to work.) – Jake Feb 22 '14 at 02:01

1 Answers1

0

Following Richard's advice, I finally got around this problem using Selenium's JS executor. I basically did what was suggested in this answer.

In one process,

command = "window.frames['IFrame1'].document.getElementById('elementInFrame1')"
driver.execute_script(command)

And the same thing in another process,

command = "window.frames['IFrame2'].document.getElementById('elementInFrame2')"
driver.execute_script(command)
Community
  • 1
  • 1
Jake
  • 228
  • 1
  • 2
  • 14