humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
Changelog
get_all_by_href
get_all_by_href($href,$exactly=false,$frame="-1"); - Получить все интерфейсы по атрибуту hrefФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Get all elements by href attribute from a collection // Description: This example demonstrates how to get a collection of elements and then find all elements with a specific href attribute within that collection // Classes used: XHEInterfaces, XHEAnchor, 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 . "anchors.html"); // Example: Get all anchor elements and then find all anchors with a specific href attribute within that collection // Get all anchor elements on the page $anchors = DOM::$anchor->get_all(); // Check that we have found at least one anchor if ($anchors->count() > 0) { echo "Found " . $anchors->count() . " anchor elements\n"; // Try to find all anchors with a specific href (exact match) $targetHref = "http://example.com"; $anchorsByHref = $anchors->get_all_by_href($targetHref, true); // Check if any anchors with the specified href were found if ($anchorsByHref->count() > 0) { echo "\nFound " . $anchorsByHref->count() . " anchor elements with href '" . $targetHref . "' (exact match):\n"; // Process each found anchor for ($k = 0; $k < $anchorsByHref->count(); $k++) { $currentAnchor = $anchorsByHref->get($k); if ($currentAnchor && $currentAnchor->is_exist()) { echo "\nAnchor #" . ($k + 1) . " with href '" . $targetHref . "':\n"; echo "Anchor inner text: " . $currentAnchor->get_inner_text() . "\n"; echo "Anchor inner number: " . $currentAnchor->inner_number . "\n"; echo "Anchor name: " . $currentAnchor->get_name() . "\n"; } } } else { echo "\nNo anchor elements with href '" . $targetHref . "' (exact match) found in the collection\n"; } // Try to find all anchors with a partial href match $partialHref = "example"; $anchorsByPartialHref = $anchors->get_all_by_href($partialHref, false); // Check if any anchors with the partial href were found if ($anchorsByPartialHref->count() > 0) { echo "\nFound " . $anchorsByPartialHref->count() . " anchor elements with partial href '" . $partialHref . "':\n"; // Process each found anchor for ($k = 0; $k < $anchorsByPartialHref->count(); $k++) { $currentAnchor = $anchorsByPartialHref->get($k); if ($currentAnchor->is_exist()) { echo "\nAnchor #" . ($k + 1) . " with partial href '" . $partialHref . "':\n"; echo "Anchor inner text: " . $currentAnchor->get_inner_text() . "\n"; echo "Anchor inner number: " . $currentAnchor->inner_number . "\n"; echo "Full href: " . $currentAnchor->get_href() . "\n"; } } } else { echo "\nNo anchor elements with partial href '" . $partialHref . "' found in the collection\n"; } // Try to find all anchors with a non-existent href $nonExistentHref = "http://nonexistent.com"; $anchorsByNonExistentHref = $anchors->get_all_by_href($nonExistentHref, true); // Check if any anchors with the non-existent href were found if ($anchorsByNonExistentHref->count() > 0) { echo "\nUnexpectedly found " . $anchorsByNonExistentHref->count() . " anchor elements with href '" . $nonExistentHref . "'\n"; } else { echo "\nAs expected, no anchor elements with href '" . $nonExistentHref . "' found in the collection\n"; } // Display all anchor hrefs in the collection for reference echo "\nAll anchor hrefs in the collection:\n"; for ($k = 0; $k < $anchors->count(); $k++) { $currentAnchor = $anchors->get($k); if ($currentAnchor->is_exist()) { $anchorHref = $currentAnchor->get_href(); $anchorInnerText = $currentAnchor->get_inner_text(); echo "Anchor #" . ($k + 1) . ": Href = '" . $anchorHref . "', Text = '" . $anchorInnerText . "'\n"; } } } else { echo "No anchor 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/anchor.html"),"<br>") # 2 echo("2. Получить все ссылки : ") anchors=anchor.get_all() echo(anchors.get_count(),"<br>") # 3 echo("3. Получим внутренний текст ссылок с href, содержащим # : <br>") anchors_1=anchors.get_all_by_href("#") print(anchors_1.get_inner_text()) # 4 echo("4. Получим внутренний текст ссылок с href = http://www.igvard.blogspot.com/ : <br>") anchors_2=anchors.get_all_by_href("http://www.igvard.blogspot.com/",true) print(anchors_2.get_inner_text()) # конец 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_all_by_href</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. Получим внутренний текст ссылок с href, содержащим # : \n\n"); XHEInterfaces anchors_1=anchors.get_all_by_href("#"); echo(anchors_1.get_inner_text()); // 4 шаг echo("\n4. Получим внутренний текст ссылок с href = http://www.igvard.blogspot.com/ : \n\n"); XHEInterfaces anchors_2=anchors.get_all_by_href("http://www.igvard.blogspot.com/",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_href</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. Получим внутренний текст ссылок с href, содержащим # : \n\n"); anchors_1=anchors.get_all_by_href("#"); echo(anchors_1.get_inner_text()); // 4 шаг echo("\n4. Получим внутренний текст ссылок с href = http://www.igvard.blogspot.com/ : \n\n"); anchors_2=anchors.get_all_by_href("http://www.igvard.blogspot.com/",true); echo(anchors_2.get_inner_text()); // конец echo("\n"); // Quit app.quit();
=============================================
Interfaces Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.