1

iPAD ISSUE. I'm trying to switch to first iFrame with Selenium, and it's not working in iPad Virtual Machine.

public void swichToFirstFrame(WebDriver driver){
    driver.switchTo().window(driver.getWindowHandle());
}

Is other way to make this switch?

This is working in Windows and Linux.

The Case: I need to switch to iFrame (iFrame1).

  1. I switch to root iFrame (iFrame0).
  2. Then switch to the iFrame (iFrame1).
  3. Selenium throw that did not found iFrame1 but in Windows and Linux this works.
Eugenio Valeiras
  • 980
  • 1
  • 9
  • 30
  • 1
    Possible duplicate of [How to switch between frames in Selenium WebDriver using Java](http://stackoverflow.com/questions/10879206/how-to-switch-between-frames-in-selenium-webdriver-using-java) – JeffC Oct 19 '15 at 15:00
  • 1
    The commands that worked for you in the answer you accepted are not specific to iPad. These commands work everywhere. You were just using the wrong command. You were trying to switch to a new frame which is what the question I linked demonstrates. That's why this question is a duplicate. – JeffC Oct 19 '15 at 15:24
  • The command I used before Its working in all the browsers except iPad, so i think is a good idea to have this issue in other question. – Eugenio Valeiras Oct 19 '15 at 15:28

2 Answers2

1

Store your iFrame in a WebElement, say iFrameWebElement

Try,

driver.switchTo().frame(iFrameWebElement);

Then remember to switch back if needed,

driver.switchTo().defaultContent();
LINGS
  • 3,560
  • 5
  • 34
  • 47
0

You could try to use a number.

Select a frame by its (zero-based) index. That is, if a page has three frames, the first frame would be at index 0, the second at index 1 and the third at index 2. Once the frame has been selected, all subsequent calls on the WebDriver interface are made to that frame.

In your case you would want to go for the 0 index, which selects the first iframe that is detected:

driver.switchTo().frame(0);

I don't know if this will help you with the iPad issue, but at least this is another possibility to make the switch...

Of course you could also identify your iframe as a WebElement first and use this, but since you wanted to always get the "first", above approach might be better.

drkthng
  • 6,651
  • 7
  • 33
  • 53
  • This is working in all the others environment, but I have the next case. I need to go inside an iFrame(iframe1) and for make this I need to go to the root frame(iframe0), Selenium is thowing me that the iFrame(iframe1) is not found, but is not throwing me that the first iframe is not found. In all the others environment its working. What is happening in iPad? – Eugenio Valeiras Oct 19 '15 at 14:37
  • ah ok, sorry I got your question wrong, but still this is another possibility to switch, But if you say that this is also not working for iPad, that's unfortunate... – drkthng Oct 19 '15 at 14:42