humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
лог изменений
wait_element_exist_by_number
wait_element_exist_by_number($number,$frame=-1); - данная функция используется для ожидания появления элемента страницы, проверяя его по заданному номеру.Доступна с версии 7.0.45
Функция на вход принимает параметры:
С версии 4.6.41 достпуно: можно передавать вложенные фреймы, принцип такой же самый, передается строка с номерами фреймов, разделенных : например при передаче "1:0:5" - будет выбран фрейм с номером 1 в нем под фрейм с номером 0 и в нем подфрейм с номером 5
С версии 7.0.38 достпуно: можно передавать "url=>XXX", тогда будет произведен поиск фрейма, который содержит заданнй src, или передавать "name=>XXX" - тогда будет поиск фрейма, по заданной части имени.
Пример использования
<?php // Scenario: Example of waiting for a DOM element to exist by its number $xhe_host = "localhost:7010"; if (!isset($path)){ // Path to the init.php file for connecting to the XHE API $path = "../../../Templates/init.php"; // Including init.php grants access to all classes and functionality for working with the XHE API require($path); } // Navigate to a webpage with anchor elements $pageUrl = TEST_POLYGON_URL . "anchor.html"; echo("Navigate to HTML page: $pageUrl\n"); WEB::$browser->navigate($pageUrl); WEB::$browser->wait_js(); // Example 1: Wait for the first anchor element on the page to exist $anchorNumber = 0; echo("\n\nExample 1: Wait for anchor element by number\n"); echo("Waiting for anchor element with number: $anchorNumber\n"); $anchorExists = DOM::$anchor->wait_element_exist_by_number($anchorNumber); if ($anchorExists) { echo("Anchor element with number $anchorNumber exists on the page\n"); // Get the anchor element to perform additional operations $findedAnchor = DOM::$anchor->get_by_number($anchorNumber); if ($findedAnchor->is_exist()) { echo("Successfully retrieved anchor element with number $anchorNumber\n"); } else { echo("Failed to retrieve anchor element with number $anchorNumber\n"); } } else { echo("Anchor element with number $anchorNumber does not exist on the page\n"); } // Example 2: Wait for an anchor element in frame 0 $frameNumber = 0; echo("\n\nExample 2: Wait for anchor element in frame\n"); echo("Frame $frameNumber exists on the page\n"); // Wait for the first anchor element in frame 0 to exist $anchorInFrameNumber = 0; echo("Waiting for anchor element with number $anchorInFrameNumber in frame $frameNumber\n"); $anchorInFrameExists = DOM::$anchor->wait_element_exist_by_number($anchorInFrameNumber, $frameNumber); if ($anchorInFrameExists) { echo("Anchor element with number $anchorInFrameNumber exists in frame $frameNumber\n"); // Get the anchor element from frame 0 $anchorInFrame = DOM::$anchor->get_by_number($anchorInFrameNumber, $frameNumber); if ($anchorInFrame->is_exist()) { echo("Successfully retrieved anchor element with number $anchorInFrameNumber from frame $frameNumber\n"); } else { echo("Failed to retrieve anchor element with number $anchorInFrameNumber from frame $frameNumber\n"); } } else { echo("Anchor element with number $anchorInFrameNumber does not exist in frame $frameNumber\n"); } // Quit the application WINDOW::$app->quit();
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7010" from xweb_human_emulator import * # начало echo("<hr><font color=blue>common.wait_element_exist_by_number</font><hr>") # 1 echo("1. Перейдем на полигон : ") echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/anchor.html"),"<br>") # 2 echo("2. Подождём ссылку с номером 9 : ") anchor.wait_element_exist_by_number(9) # 2 echo("2. Кликнем по 9 элементу : ") echo(anchor.click_by_number(9),"<br>") # конец echo("<hr><br>") # Quit app.quit()
#region using using System; using System.Diagnostics; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Threading; using XHE; using XHE.XHE_DOM; using XHE.XHE_System; using XHE.XHE_Window; using XHE.XHE_Web; #endregion class Program:XHEScript { static void Main(string[] args) { // init XHE server = "localhost:7010"; InitXHE(); // начало echo("<hr><font color=blue>wait_element_exist_by_number</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("rpa-bot.ru/wiki/poligon/anchor.html")+"<br>"); // 2 шаг echo("2. Подождём ссылку с номером 9 : "); echo(anchor.wait_element_exist_by_number(9,"-1")+"<br>"); // 3 шаг echo("3. Кликнем по 9 элементу : "); echo(anchor.click_by_number(9)+"<br>"); // конец echo("\n\n"); app.quit(); } }
// IE + Chrom // подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7010"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>element.wait_element_exist_by_number</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/anchor.html")+"<br>"); // 2 шаг echo("2. Ожидаем ссылку с номером 9 : "); anchor.wait_element_exist_by_number(9); // 2 шаг echo("2. Кликнем по 9 элементу : "); echo(anchor.click_by_number(9)+"<br>"); // конец echo("\n"); // Quit app.quit();
=============================================
Общие функции Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.
PS: В тестовом примере приведена работа с конкретным объектом DOM, но данная функция есть во всех DOM объектах, т.е она существует у всех объектов из категории DOM.