0
<iframe id="vacancy_department_requirements_ifr" frameborder="0" src="javascript:""" allowtransparency="true" title="Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help" style="width: 100%; height: 100px; display: block;">
<!DOCTYPE html>
<html>

I am having problem in switching the iframes while automating the application using webdriver. There are three texteditor. And when I do inspect element then at the same iframe id the id changes. so I am unable to switch in between the frames.

I wrote the following code:-

wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("vacancy_job_requirements_ifr"));


WebElement element2 = driver.findElement(By.cssSelector("body"));
JavascriptExecutor executor3 = (JavascriptExecutor)driver;
executor3.executeScript("arguments[0].innerHTML = '<h1>Set text using innerHTML2</h1>'", element2);
        */
        /*wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("vacancy_job_description_ifr"));

WebElement element3 = driver.findElement(By.cssSelector("body"));
JavascriptExecutor executor4 = (JavascriptExecutor)driver;
executor4.executeScript("arguments[0].innerHTML = '<h1>Set text using innerHTML2 gf</h1>'", element3);


        wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("vacancy_department_requirements_ifr"));
 WebElement element4 = driver.findElement(By.cssSelector("body"));
JavascriptExecutor executor5 = (JavascriptExecutor)driver;
executor5.executeScript("arguments[0].innerHTML = '<h1>Set text using innerHTML3 gf</h1>'", element4);*/

But the above code is giving me following error: "Timed out after 120 seconds waiting for frame to be available: vacancy_job_description_ifr'

Please suggest.

Alpha
  • 13,320
  • 27
  • 96
  • 163
Poorva
  • 99
  • 1
  • 1
  • 2
  • It's similar to this question, Please go through it. [enter link description here][1] [1]: http://stackoverflow.com/questions/16096993/webdriver-switch-between-sibling-frames – user3603856 May 06 '14 at 10:01

2 Answers2

0

You can switch frame by its index i.e. driver.switchTo().frame(). Find the number of frames and switch to frame by providing its index value.

Refer link (How to switch between frames in Selenium WebDriver using Java)

Community
  • 1
  • 1
Ashish
  • 51
  • 3
0

Use driver.switchTo().frame(driver.findElement(By.id("pvacancy_department_requirements_ifr")));

Sujay
  • 139
  • 1
  • 9