humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
Changelog
get_all_by_attribute
get_all_by_attribute($attr_name,$attr_value,$exactly=false,$frame="-1"); - Получить все интерфейсы по атрибутуФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Get all elements by attribute from a collection // Description: This example demonstrates how to get a collection of elements and then find all elements with a specific attribute within that collection // Classes used: XHEInterfaces, XHEDiv, 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 . "divs.html"); // Example: Get all div elements and then find all divs with a specific attribute within that collection // Get all div elements on the page $divs = DOM::$div->get_all(); // Check that we have found at least one div if ($divs->count() > 0) { echo "Found " . $divs->count() . " div elements\n"; // Try to find all divs with a specific ID attribute (exact match) $targetAttrName = "id"; $targetAttrValue = "example"; $divsByAttr = $divs->get_all_by_attribute($targetAttrName, $targetAttrValue, true); // Check if any divs with the specified attribute were found if ($divsByAttr->count() > 0) { echo "\nFound " . $divsByAttr->count() . " div elements with attribute '" . $targetAttrName . "' = '" . $targetAttrValue . "' (exact match):\n"; // Process each found div for ($k = 0; $k < $divsByAttr->count(); $k++) { $currentDiv = $divsByAttr->get($k); if ($currentDiv->is_exist()) { echo "\nDiv #" . ($k + 1) . " with attribute '" . $targetAttrName . "' = '" . $targetAttrValue . "':\n"; echo "Div inner text: " . $currentDiv->get_inner_text() . "\n"; echo "Div inner number: " . $currentDiv->inner_number . "\n"; // Get the class attribute of the found div $divClass = $currentDiv->get_attribute("class"); echo "Div class: " . $divClass . "\n"; } } } else { echo "\nNo div elements with attribute '" . $targetAttrName . "' = '" . $targetAttrValue . "' (exact match) found in the collection\n"; } // Try to find all divs with a partial class attribute match $partialAttrName = "class"; $partialAttrValue = "example"; $divsByPartialAttr = $divs->get_all_by_attribute($partialAttrName, $partialAttrValue, false); // Check if any divs with the partial attribute were found if ($divsByPartialAttr->count() > 0) { echo "\nFound " . $divsByPartialAttr->count() . " div elements with partial attribute '" . $partialAttrName . "' = '" . $partialAttrValue . "':\n"; // Process each found div for ($k = 0; $k < $divsByPartialAttr->count(); $k++) { $currentDiv = $divsByPartialAttr->get($k); if ($currentDiv->is_exist()) { echo "\nDiv #" . ($k + 1) . " with partial attribute '" . $partialAttrName . "' = '" . $partialAttrValue . "':\n"; echo "Div inner text: " . $currentDiv->get_inner_text() . "\n"; echo "Div inner number: " . $currentDiv->inner_number . "\n"; echo "Full class attribute: " . $currentDiv->get_attribute("class") . "\n"; } } } else { echo "\nNo div elements with partial attribute '" . $partialAttrName . "' = '" . $partialAttrValue . "' found in the collection\n"; } // Try to find all divs with another attribute $targetAttrName2 = "data-type"; $targetAttrValue2 = "test"; $divsByAttr2 = $divs->get_all_by_attribute($targetAttrName2, $targetAttrValue2, true); // Check if any divs with the specified attribute were found if ($divsByAttr2->count() > 0) { echo "\nFound " . $divsByAttr2->count() . " div elements with attribute '" . $targetAttrName2 . "' = '" . $targetAttrValue2 . "':\n"; // Process each found div for ($k = 0; $k < $divsByAttr2->count(); $k++) { $currentDiv = $divsByAttr2->get($k); if ($currentDiv->is_exist()) { echo "\nDiv #" . ($k + 1) . " with attribute '" . $targetAttrName2 . "' = '" . $targetAttrValue2 . "':\n"; echo "Div inner text: " . $currentDiv->get_inner_text() . "\n"; echo "Div inner number: " . $currentDiv->inner_number . "\n"; } } } else { echo "\nNo div elements with attribute '" . $targetAttrName2 . "' = '" . $targetAttrValue2 . "' found in the collection\n"; } } else { echo "No div 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:7013" 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/anchor.html"),"<br>") # 2 echo("2. Получить все ссылки : ") anchors=anchor.get_all() echo(anchors.get_count(),"<br>") # 3 echo("3. Получим атирибут ссылок с name, содержащим onmouseover : <br>") anchors_1=anchors.get_all_by_attribute("name","onclick") res = anchors_1.get_attribute('name') print(res) # 4 echo("4. Получим xpath ссылок с name = bigfozzy : <br>") anchors_2=anchors.get_all_by_attribute("name","bigfozzy",true) print(anchors_2.get_xpath()) # 5 echo("5. Получим x координату ссылок с name = bigfozzy : <br>") anchors_3=anchors.get_all_by_attribute("name","bigfozzy",true) print(anchors_3.get_x()) # 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_all_by_attribute</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("rpa-bot.ru/wiki/poligon/anchor.html")+"<br>"); // 2 шаг echo("2. Получить количество всех ссылок : "); XHEInterfaces anchors=anchor.get_all(); echo(anchors.get_count()+"<br>"); // 3 шаг echo("3. Получим внутренний текст ссылок с name, содержащим onmouseover : \n\n"); XHEInterfaces anchors_1=anchors.get_all_by_attribute("name","onmouseover"); echo(anchors_1.get_inner_text()); // 4 шаг echo("\n4. Получим внутренний текст ссылок с name = bigfozzy : \n\n"); XHEInterfaces anchors_2=anchors.get_all_by_attribute("name","bigfozzy",true); echo(anchors_2.get_inner_text()); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7010"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>interface.get_all_by_attribute</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/anchor.html")+"<br>"); // 2 шаг echo("2. Получить все ссылки : "); anchors=anchor.get_all(); echo(anchors.get_count()+"<br>"); // 3 шаг echo("3. Получим внутренний текст ссылок с name, содержащим onmouseover : \n\n"); anchors_1=anchors.get_all_by_attribute("name","onmouseover"); echo(anchors_1.get_inner_text()); // 4 шаг echo("\n4. Получим внутренний текст ссылок с name = bigfozzy : \n\n"); anchors_2=anchors.get_all_by_attribute("name","bigfozzy",true); echo(anchors_2.get_inner_text()); // конец echo("\n"); // Quit app.quit();
=============================================
Interfaces Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.