Основной сайт хуманэмулятор.рф | Демо | Купить | API | Wiki
DOM / interfaces
get_all_by_inner_text
get_all_by_inner_text($inner_text,$exactly=false,$frame="-1"); - Получить все интерфейсы по внутреннему текстуФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Get all elements by inner text from a collection // Description: This example demonstrates how to get a collection of elements and then find all elements with specific inner text 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 specific inner text 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 inner text (exact match) $targetText = "Example"; $anchorsByText = $anchors->get_all_by_inner_text($targetText, true); // Check if any anchors with the specified inner text were found if ($anchorsByText->count() > 0) { echo "\nFound " . $anchorsByText->count() . " anchor elements with inner text '" . $targetText . "' (exact match):\n"; // Process each found anchor for ($k = 0; $k < $anchorsByText->count(); $k++) { $currentAnchor = $anchorsByText->get($k); if ($currentAnchor->is_exist()) { echo "\nAnchor #" . ($k + 1) . " with inner text '" . $targetText . "':\n"; echo "Anchor href: " . $currentAnchor->get_href() . "\n"; echo "Anchor inner number: " . $currentAnchor->inner_number . "\n"; } } } else { echo "\nNo anchor elements with inner text '" . $targetText . "' (exact match) found in the collection\n"; } // Try to find all anchors with a partial inner text match $partialText = "Exam"; $anchorsByPartialText = $anchors->get_all_by_inner_text($partialText, false); // Check if any anchors with the partial inner text were found if ($anchorsByPartialText->count() > 0) { echo "\nFound " . $anchorsByPartialText->count() . " anchor elements with partial inner text '" . $partialText . "':\n"; // Process each found anchor for ($k = 0; $k < $anchorsByPartialText->count(); $k++) { $currentAnchor = $anchorsByPartialText->get($k); if ($currentAnchor->is_exist()) { echo "\nAnchor #" . ($k + 1) . " with partial inner text '" . $partialText . "':\n"; echo "Anchor href: " . $currentAnchor->get_href() . "\n"; echo "Anchor inner number: " . $currentAnchor->inner_number . "\n"; echo "Full inner text: " . $currentAnchor->get_inner_text() . "\n"; } } } else { echo "\nNo anchor elements with partial inner text '" . $partialText . "' found in the collection\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("http://www.humanemulator.net/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_inner_text("ссылка") print(anchors_1.get_href()) # 4 echo("4. Получим href ссылок с хтмл = Блог : <br>") anchors_2=anchors.get_all_by_inner_text("Блог",true) print(anchors_2.get_href()) # конец 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="127.0.0.1:7010"; InitXHE(); // начало echo("<hr><font color=blue>interfaces.get_all_by_inner_text</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("www.humanemulator.net/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_inner_text("ссылка"); echo(anchors_1.get_href()); // 4 шаг echo("\n4. Получим href ссылок с хтмл = Блог : \n\n"); XHEInterfaces anchors_2=anchors.get_all_by_inner_text("Блог",true); echo(anchors_2.get_href()); // конец echo("<hr><br>"); app.quit(); } }
// подключим объект для управления эмулятором, если еще не подключен xhe_host="127.0.0.1:7010"; echo=require("../../../Templates JS/xweb_human_emulator.js"); // начало echo("<hr><font color=blue>interface.get_all_by_inner_text</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("http://www.humanemulator.net/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_inner_text("ссылка"); echo(anchors_1.get_href()); // 4 шаг echo("\n4. Получим href ссылок с хтмл = Блог :\n\n"); anchors_2=anchors.get_all_by_inner_text("Блог",true); echo(anchors_2.get_href()); // конец echo("<hr><br>"); // Quit app.quit();
=============================================
Interfaces Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.