Вы просматриваете старую версию данной страницы. Смотрите текущую версию.

Сравнить с текущим просмотр истории страницы

« Предыдущий Версия 5 Следующий »

Switch to frame Version 13 (Java)

Action group: Browsers


Description 

The action switches the control focus on the currently active page to the specified frame. A frame is a separate, complete HTML document that, together with other HTML documents, can be displayed in a browser window. Frames can also be nested within a frame, and frames can also be nested within frames. Frames divide a web page into separate minicomics on the same screen, which are independent of each other. Each window can have its own address.

Web elements that are inside a frame located on a web page are isolated from elements on the page itself and elements inside other frames on the page. Elements within a frame are not available to be manipulated by actions until you switch to that frame.

For a deeper understanding of the structure of frames and the principles of their construction, read the information on the links below:

Technically, the action moves the control focus through the frame structure. This is done by specifying the target frame to move to and the search area of that frame.

Action icon 

Settings of parameters

Свойство

Описание

Тип

Пример заполнения

Обязательность 

заполнения поля

Параметры

Контекст

Контекст действия для работы с браузером.

Robin.Selenium

Контекст браузера

Да

Элемент

Фрейм, как элемент для взаимодействия

Robin.WebElement

/html/body/div[5]/div[4]/div/div

Нет

Имя

Имя фрейма

Robin.String

iframeResult

Нет

Индекс

Индекс фрейма. Нумерация начинается с 0.

Robin.Numeric

1

Нет

Область поиска фрейма

Область поиска фрейма. Доступно 3 варианта: текущий фрейм - поиск в рамках текущего фрейма; родительский фрейм - поиск в рамках родительского фрейма; вся страница - поиск в рамках всей страницы.

Robin.String

Родительский фрейм

Нет

Special conditions of use

  • Frame elements are not available when working with page elements. In order to access the frame elements, you must switch to it.
  • When working with frame elements, page elements are not available. In order to continue working with page elements, you need to switch from the frame back to the page.
  • It is also possible to switch to the current tab again using the "Switch to Tab" action.
  • To determine the number of frames on the page and their attributes, it is necessary to use the developer console. The console is opened by pressing the F12 key in the browser where the iframe is displayed (if there is one on the page).

Browser page with the developer console open:


As part of the example of filling out the "Frame search area" field, consider a site with frames: https://www.tutorialspoint.com/html/html_frames.htm , as well as the robot scheme Frames (1).robin-source

An example of using an action using the "Index" parameter and "Frame search area" parameter options:

Task 1

Implement actions using the "Index" parameter and "Frame search area" parameter options.

  1. The Parent frame option - we will search in a frame that is a level higher than the current focus (frame), or when the focus is on the main page. There are 3 frames on the site (you can see them using the developer console). To switch to the third frame, let's fill in the parameters: 
    • Specify "2" in the "Index" field (frame numbering starts with zero).
    • Specify "Parent frame" in the "Frame search area" field.
    • Specify the open browser context in the "Context" field.
    • Specify "Parent frame" in the "Frame search area" field (as the focus is now on the main page)


 

The frame (the one switched to) contains two frames.

2. Опция Текущий фрейм - ищем фрейм в внутри текущего фрейма. Переключимся на фрейм с текстом "This is main page and content from any link will be displayed here". Это второй фрейм внутри текущего фрейма. Укажем параметры действия:

    • в поле "Контекст" укажем контекст открытого браузера,
    • в поле "Индекс" укажем значение 1 (нумерация фреймов начинается с 0),
    • в поле "Область поиска фрейма" укажем значение "Текущий фрейм"  (ищем дочерний фрейм в текущем фрейм).

 
 

Далее, с помощью действие "Получить текст" получим текст из фрейма (см. приложенную к описанию схему робота).

3. Опция Вся страница выполним переключение фокуса из фрейма на основную страницу. Для этого указываем опцию "Вся страница" и контекст открытого браузера. Остальные параметры оставьте пустыми. 

Выполним действие "Получить текст" из основной страницы (см. приложенную к описанию схему робота). 

Задача 2

Зайти на сайт с фреймом https://www.w3schools.com/css/tryit.asp?filename=trycss_default, переключиться на него для дальнейшей работы с ним и получить текст из фрейма "My First CSS Example". 

Реализовать действие с использованием параметров "Имя", "Элемент" и опций "Область поиска".

Решение

Воспользоваться действиями "Открыть браузер", "Переключиться на фрейм", "Получить текст". 

Реализация

  1. Собрать робота, состоящего из действий:
  2. Настроить параметры для действия "Открыть браузер". 


  3. Настроить параметр для действия "Переключиться на фрейм". 
  4. Настроить параметры для действия "Получить текст". В поле "Элемент" необходимо указать элемент из которого необходимо получить текст. Подробнее о создании элементов в разделе: Create Web-elements


  5. Нажать на кнопку "Старт" в верхней панели. 

Результат

Программный робот отработал успешно. 


В данном случае, если отключить действие "Переключиться на фрейм", то элемент не будет найден,  так как поиск элемента осуществляется в текущем документе, а сам элемент находится во вложенном. 

  • Нет меток