Основной сайт хуманэмулятор.рф | Демо | Купить | API | Wiki
DOM / interfaces
get_by_inner_html
get_by_inner_html($inner_html,$exactly=true); - Получить интерфейс по внутреннему HTMLФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Get elements by inner HTML from a collection // Description: This example demonstrates how to get a collection of elements and then find specific elements by their inner HTML 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 specific divs by their inner HTML 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 a div with a specific inner HTML (exact match) in div elements $targetHtml = "<p>Example paragraph</p>"; $divByHtml = $divs->get_by_inner_html($targetHtml, true); // Check if the div with the specified inner HTML was found in div elements and exists if ($divByHtml && $divByHtml->is_exist()) { echo "\nFound div with inner HTML '" . $targetHtml . "' (exact match):\n"; echo "Div inner number: " . $divByHtml->inner_number . "\n"; echo "Div ID: " . $divByHtml->get_id() . "\n"; } else { echo "\nNo div with inner HTML '" . $targetHtml . "' (exact match) found in the collection\n"; } // Try to find a div with a partial inner HTML match in div elements $partialHtml = "Example"; $divByPartialHtml = $divs->get_by_inner_html($partialHtml, false); // Check if the div with the partial inner HTML was found in div elements and exists if ($divByPartialHtml && $divByPartialHtml->is_exist()) { echo "\nFound div with partial inner HTML '" . $partialHtml . "':\n"; echo "Div inner number: " . $divByPartialHtml->inner_number . "\n"; echo "Div ID: " . $divByPartialHtml->get_id() . "\n"; echo "Full inner HTML: " . $divByPartialHtml->get_inner_html() . "\n"; } else { echo "\nNo div with partial inner HTML '" . $partialHtml . "' found in the collection\n"; } // Try to find a div with another inner HTML in div elements $targetHtml2 = "<span>Test</span>"; $divByHtml2 = $divs->get_by_inner_html($targetHtml2, true); // Check if the div with the specified inner HTML was found in div elements and exists if ($divByHtml2 && $divByHtml2->is_exist()) { echo "\nFound div with inner HTML '" . $targetHtml2 . "':\n"; echo "Div inner number: " . $divByHtml2->inner_number . "\n"; echo "Div ID: " . $divByHtml2->get_id() . "\n"; } else { echo "\nNo div with inner HTML '" . $targetHtml2 . "' 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: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. Получим размеры ссылки с хтмл = ссылка onmouseover : ") onmouseover_anchor=anchors.get_by_inner_html("ссылка onmouseover") echo(onmouseover_anchor.get_width()," x ") echo(onmouseover_anchor.get_height(),"<br>") # 4 echo("4. Получим размеры ссылки с хтмл, содержащей SEO : ") onmouseover_anchor=anchors.get_by_inner_html("SEO",false) echo(onmouseover_anchor.get_width()," x ") echo(onmouseover_anchor.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="127.0.0.1:7010"; InitXHE(); // начало echo("<hr><font color=blue>interfaces.get_by_inner_html</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. Получим размеры ссылки с хтмл = ссылка onmouseover : "); XHEInterface onmouseover_anchor=anchors.get_by_inner_html("ссылка onmouseover"); echo(onmouseover_anchor.get_width()+" x "+onmouseover_anchor.get_height()+"<br>"); // 4 шаг echo("4. Получим размеры ссылки с хтмл, содержащей SEO : "); XHEInterface seo_anchor=anchors.get_by_inner_html("SEO",false); echo(seo_anchor.get_width()+" x "+seo_anchor.get_height()+"<br>"); // конец echo("<hr><br>"); app.quit(); } }
// IE + Chrom // подключим объект для управления эмулятором, если еще не подключен xhe_host="127.0.0.1:7010"; echo=require("../../../Templates JS/xweb_human_emulator.js"); // начало echo("<hr><font color=blue>interface.get_by_inner_html</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. Получим размеры ссылки с хтмл = ссылка onmouseover : "); onmouseover_anchor=anchors.get_by_inner_html("ссылка onmouseover"); echo(onmouseover_anchor.get_width()+" x "+onmouseover_anchor.get_height()+"<br>"); // 4 шаг echo("4. Получим размеры ссылки с хтмл, содержащей SEO : "); onmouseover_anchor=anchors.get_by_inner_html("SEO",false); echo(onmouseover_anchor.get_width()+" x "+onmouseover_anchor.get_height()+"<br>"); // конец echo("<hr><br>"); // Quit app.quit();
=============================================
Interfaces Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.