wait_element_exist_by_attribute_by_form_number
wait_element_exist_by_attribute_by_form_number($attr_name,$attr_value,$exactly,$form_number,$frame=-1); - данная функция используется для ожидания появления элемента страницы, проверяя его по значению заданного аттрибута в форме с заданным номером.Доступна с версии 7.0.45
Функция на вход принимает параметры:
С версии 4.6.41 достпуно: можно передавать вложенные фреймы, принцип такой же самый, передается строка с номерами фреймов, разделенных : например при передаче "1:0:5" - будет выбран фрейм с номером 1 в нем под фрейм с номером 0 и в нем подфрейм с номером 5
С версии 7.0.38 достпуно: можно передавать "url=>XXX", тогда будет произведен поиск фрейма, который содержит заданнй src, или передавать "name=>XXX" - тогда будет поиск фрейма, по заданной части имени.
Время ожидания элемента задаётся с помощью переменной $iSecondsWaitElementExistBeforeAction=15; // сколько секунд ждать появления элемента определённой в файле шаблона xweb_human_emulator для каждого языка.
<?php // Scenario: Example of waiting for a DOM element to exist by its attribute within a specific form by 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 DOM elements and forms $pageUrl = TEST_POLYGON_URL . "form.html"; echo("Navigate to HTML page: $pageUrl\n"); WEB::$browser->navigate($pageUrl); WEB::$browser->wait_js(); // Example 1: Wait for an element with attribute "name" equal to "username" within form number 0 to exist $attributeName1 = "name"; $attributeValue1 = "username"; $exactMatch1 = true; $formNumber1 = 0; echo("\n\nExample 1: Wait for element to exist by attribute within form by form number\n"); $elementExists = DOM::$input->wait_element_exist_by_attribute_by_form_number($attributeName1, $attributeValue1, $exactMatch1, $formNumber1); if ($elementExists) { echo "Example 1: Element with attribute '$attributeName1' equal to '$attributeValue1' exists in form number $formNumber1\n"; // Get the element to perform additional operations $findedElement = DOM::$input->get_by_attribute($attributeName1, $attributeValue1); if ($findedElement->is_exist()) { echo "Example 1: Successfully retrieved element with attribute '$attributeName1' equal to '$attributeValue1' from form number $formNumber1\n"; echo "Example 1: Element tag name: " . $findedElement->get_name() . "\n"; } else { echo "Example 1: Failed to retrieve element with attribute '$attributeName1' equal to '$attributeValue1' from form number $formNumber1\n"; } } else { echo "Example 1: Element with attribute '$attributeName1' equal to '$attributeValue1' does not exist in form number $formNumber1\n"; } // Example 2: Wait for button element with exact match parameter $attributeName2 = "type"; $attributeValue2 = "submit"; $exactMatch2 = true; $formNumber2 = 0; echo("\n\nExample 2: Wait for button element to exist by attribute with exact match\n"); $elementExistsExact = DOM::$button->wait_element_exist_by_attribute_by_form_number($attributeName2, $attributeValue2, $exactMatch2, $formNumber2); if ($elementExistsExact) { echo "Example 2: Button element with exact attribute '$attributeName2' equal to '$attributeValue2' exists in form number $formNumber2\n"; } else { echo "Example 2: Button element with exact attribute '$attributeName2' equal to '$attributeValue2' does not exist in form number $formNumber2\n"; } // Example 3: Wait for radio button element in form number 1 $attributeName3 = "name"; $attributeValue3 = "sex"; $exactMatch3 = false; $formNumber3 = 1; echo("\n\nExample 3: Wait for radio button element to exist by attribute within different form number\n"); $elementExistsByClass = DOM::$radiobox->wait_element_exist_by_attribute_by_form_number($attributeName3, $attributeValue3, $exactMatch3, $formNumber3); if ($elementExistsByClass) { echo "Example 4: Radio button element with attribute '$attributeName3' equal to '$attributeValue3' exists in form number $formNumber3\n"; } else { echo "Example 4: Radio button element with attribute '$attributeName3' equal to '$attributeValue3' does not exist in form number $formNumber3\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_attribute_by_form_number</font><hr>") # 1 echo("1. Перейдем на полигон : ") echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/button.html"),"<br>") # 2 echo("2. Подождём элемент с именем btn1f в форме с с номером 0 : ") button.wait_element_exist_by_attribute_by_form_number("name","btn1f",true,0) # 3 echo("3. Кликнем на элементе с именем btn1f в форме с с номером 0 : ") echo(button.click_by_attribute_by_form_number("name","btn1f",true,0),"<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_attribute_by_form_number</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("rpa-bot.ru/wiki/poligon/button.html")+"<br>"); // 2 шаг echo("2. Ожидаем элемент с именем btn1f в форме с с номером 0 : "); button.wait_element_exist_by_attribute_by_form_number("name","btn1f",1,0,"-1"); // 3 шаг echo("3. Кликнем на элементе с именем btn1f в форме с с номером 0 : "); echo(button.click_by_attribute_by_form_number("name","btn1f",1,0)+"<br>"); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7010"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>common.wait_element_exist_by_attribute_by_form_number</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/button.html")+"<br>"); // 2 шаг echo("2. Ожидаем элемент с именем btn1f в форме с с номером 0 : "); button.wait_element_exist_by_attribute_by_form_number("name","btn1f",true,0); // 2 шаг echo("2. Кликнем на элементе с именем btn1f в форме с с номером 0 : "); echo(button.click_by_attribute_by_form_number("name","btn1f",true,0)+"<br>"); // конец echo("\n"); // Quit app.quit();
=============================================
Общие функции Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.
PS: В тестовом примере приведена работа с конкретным объектом DOM, но данная функция есть во всех DOM объектах, т.е она существует у всех объектов из категории DOM.