Cannot switch focus into a dynamically loaded iframe in Safari using webdriver.io

I am writing automated E2E tests using webdriver.io but I am having trouble when trying to run the tests on safari. The page that I am trying to test has a bunch of different iframes on it and I need to be able to switch focus between all of these iframes to access the elements I need. The problem I am running into is that, in safari, if a frame is loaded dynamically (not loaded at the same time as the page) I cannot switch focus into that frame. The test suite I am using works well on Chrome and Firefox, I am only seeing this issue in safari. I am assuming it is a bug in the safari driver bundled with the browser but I haven't had a whole lot of luck with apple support on this issue. I am hoping there might be a way to work around this issue without a fix from apple.

Here is the page I am trying to test: http://test.spotx.tv/test/ad/js/ados/ima/test.html?vpaid=JS&channel_id=209244&vpi=None&vpaid_mode=2&content_page_url=http%3A%2F%2Fany_non_blacklisted_domain.com

So if you go to that page and click the big play button at the bottom a snowboarding video should load. This is also when the iframes I need to access get loaded. Basically what my test is doing is trying to click on the players pause button but that button exists inside of an iframe which I cannot switch focus to. The button exists in the third iframe on the page.

<iframe width="640" height="360" frameborder="0" scrolling="no" allowfullscreen="true" style="position: absolute; z-index: 10; left: 0px; top: 0px;"></iframe>

In webdriver.io the way to switch focus to an iframe is to use browser.frame($('iframe[frameborder^="0"]').value); When I run this line there are no errors reported or any indication that the command failed but if I check the iframe context after running this line I can see that I am still at the document root context not inside the iframe I need.

Luckily webdriver.io has some pretty good debug tools and I can see exactly what is contained in the value attribute of the iframe I want. The problem is that the ELEMENT attribute is being reported as undefined.

{ sessionId: 'D2CA7027-4DBC-41E9-8D2B-30CEC88C9D34',
  value:
   [ { ELEMENT: undefined,
       'element-6066-11e4-a52e-4f735466cecf': undefined } ],
  selector: 'iframe[frameborder^="0"]',
  _status: 0 }

If I run the exact same test in chrome or firefox the ELEMENT attribute has a value and switching to the frame works in both of those browsers.

Chrome:

{ sessionId: 'a7b6ed418a8dbb7e36e907170c22bd84',
  value:
   [ { ELEMENT: '0.797140656478291-3',
       'element-6066-11e4-a52e-4f735466cecf': '0.797140656478291-3',
       selector: 'iframe[frameborder^="0"]',
       value: [Object],
       index: 0 } ],
  selector: 'iframe[frameborder^="0"]',
  _status: 0 }

Firefox:

{ state: 'success',
  sessionId: null,
  hCode: 371926366,
  value:
   [ { ELEMENT: '92627ad9-d151-4749-91f6-58e89de5844c',
       'element-6066-11e4-a52e-4f735466cecf': '92627ad9-d151-4749-91f6-58e89de5844c',
       selector: 'iframe[frameborder^="0"]',
       value: [Object],
       index: 0 } ],
  class: 'org.openqa.selenium.remote.Response',
  selector: 'iframe[frameborder^="0"]',
  _status: 0 }

I am assuming that the selection and creation of this element object is handled by each individual browsers selenium driver which is what makes me think there is a bug in the safari driver. I have opened a bug/issue report with apple but it has been 5+ months and there still has not been a fix so I have to start looking down other avenues.

Any suggestions for work arounds or fixes to be able to successfully select and switch to the required iframe would be greatly appreciated. Thanks.