humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
Changelog
get_by_value
get_by_value($value,$exactly=true); - Получить интерфейс по атрибуту valueФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Get elements by value attribute from a collection // Description: This example demonstrates how to get a collection of elements and then find specific elements by their value attribute within that collection // Classes used: XHEInterfaces, XHEInput, XHEBrowser, XHEApplication // Connection string to XHE API $xhe_host = getenv("RPABOT_HOST_URL"); // Path to init.php file if (!isset($path)) { // Path to init.php file for connecting to XHE API $path = "../../../Templates/init.php"; // When connecting init.php file, all functionality of classes for working with XHE API will be available require($path); } // Navigate to the polygon page if the page was not loaded earlier WEB::$browser->navigate(TEST_POLYGON_URL . "input.html"); // Example: Get all input elements and then find specific inputs by their value attribute within that collection // Get all input elements on the page $inputs = DOM::$input->get_all(); // Check that we have found at least one input if ($inputs->count() > 0) { echo "Found " . $inputs->count() . " input elements\n"; // Try to find an input with a specific value (exact match) in input elements $targetValue = "example"; $inputByValue = $inputs->get_by_value($targetValue, true); // Check if the input with the specified value was found in input elements and exists if ($inputByValue && $inputByValue->is_exist()) { echo "\nFound input with value '" . $targetValue . "' (exact match):\n"; echo "Input name: " . $inputByValue->get_name() . "\n"; echo "Input inner number: " . $inputByValue->inner_number . "\n"; echo "Input type: " . $inputByValue->get_type() . "\n"; } else { echo "\nNo input with value '" . $targetValue . "' (exact match) found in the collection\n"; } // Try to find an input with a partial value match in input elements $partialValue = "exam"; $inputByPartialValue = $inputs->get_by_value($partialValue, false); // Check if the input with the partial value was found in input elements and exists if ($inputByPartialValue && $inputByPartialValue->is_exist()) { echo "\nFound input with partial value '" . $partialValue . "':\n"; echo "Input name: " . $inputByPartialValue->get_name() . "\n"; echo "Input inner number: " . $inputByPartialValue->inner_number . "\n"; echo "Full value: " . $inputByPartialValue->get_value() . "\n"; } else { echo "\nNo input with partial value '" . $partialValue . "' found in the collection\n"; } // Try to find an input with a non-existent value in input elements $nonExistentValue = "nonexistent"; $inputByNonExistentValue = $inputs->get_by_value($nonExistentValue, true); // Check if the input with the non-existent value was found in input elements and exists if ($inputByNonExistentValue && $inputByNonExistentValue->is_exist()) { echo "\nUnexpectedly found input with value '" . $nonExistentValue . "'\n"; } else { echo "\nAs expected, no input with value '" . $nonExistentValue . "' found in the collection\n"; } } else { echo "No input elements found on the page\n"; } // Stop 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>interfaces.xxxxxxxxx</font><hr>") # 1 echo("1. Перейдем на полигон : ") echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/checkbox.html"),"<br>") # 2 echo("2. Получить все чекбоксы : ") checkboxs=checkbox.get_all() echo(checkboxs.get_count(),"<br>") # 3 echo("3. Получим размеры чекбокса с value = Linux : ") chk_01=checkboxs.get_by_value("Linux") echo(chk_01.get_width()," x ") echo(chk_01.get_height(),"<br>") # 4 echo("4. Получим размеры чекбокса с value, содержащей X : ") chk_02=checkboxs.get_by_value("X",false) echo(chk_02.get_width()," x ") echo(chk_02.get_height(),"<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 = Environment.GetEnvironmentVariable("RPABOT_HOST_URL"); InitXHE(); // начало echo("<hr><font color=blue>interfaces.get_by_value</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("rpa-bot.ru/wiki/poligon/checkbox.html")+"<br>"); // 2 шаг echo("2. Получить все чекбоксы : "); XHEInterfaces checkboxs=checkbox.get_all(); echo(checkboxs.get_count()+"<br>"); // 3 шаг echo("3. Получим размеры чекбокса с value = Linux : "); XHEInterface chk_01=checkboxs.get_by_value("Linux"); echo(chk_01.get_width()+" x "+chk_01.get_height()+"<br>"); // 4 шаг echo("4. Получим размеры чекбокса с value, содержащей X : "); XHEInterface chk_02=checkboxs.get_by_value("X",false); echo(chk_02.get_width()+" x "+chk_02.get_height()+"<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>interface.get_by_value</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/checkbox.html")+"<br>"); // 2 шаг echo("2. Получить все чекбоксы : "); checkboxs=checkbox.get_all(); echo(checkboxs.get_count()+"<br>"); // 3 шаг echo("3. Получим размеры чекбокса с value = Linux : "); chk_01=checkboxs.get_by_value("Linux"); echo(chk_01.get_width()+" x "+chk_01.get_height()+"<br>"); // 4 шаг echo("4. Получим размеры чекбокса с value, содержащей X : "); chk_02=checkboxs.get_by_value("X",false); echo(chk_02.get_width()+" x "+chk_02.get_height()+"<br>"); // конец echo("\n"); // Quit app.quit();
=============================================
Interfaces Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.