Reputation: 11
I am new to Selenium and trying to practise with icloud.com. I wrote the code below but the frame cannot be located, but when I do on console the frame is being located.
driver.get("https://www.icloud.com");
driver.manage().window().maximize();
driver.manage().timeouts().pageLoadTimeout(3000, TimeUnit.SECONDS);
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@title='Apple Id Sign-In'][@id='auth-frame'][@class='atv4 sc-view']")));
Upvotes: 1
Views: 1492
Reputation: 7708
Actually your site take time to load iframe
Need to use ExplicitWait
to visibility of iframe
driver.get("https://www.icloud.com");
driver.manage().window().maximize();
driver.manage().timeouts().pageLoadTimeout(3000, TimeUnit.SECONDS);
WebDriverWait wait =new WebDriverWait(driver, 120);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//iframe[@title='Apple Id Sign-In'][@id='auth-frame'][@class='atv4 sc-view']")));
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@title='Apple Id Sign-In'][@id='auth-frame'][@class='atv4 sc-view']")));
driver.findElement(By.id("appleId")).sendKeys("hello");
Upvotes: 1