humanemulator.net — справка. Продукт, демо и покупка — на хуманэмулятор.рф | Демо | Купить | API | лог изменений
К объекту interface

get_all_child_by_inner_text

get_all_child_by_inner_text($inner_text,$exactly=false,$include_subchildren=false); - получить все дочерние интерфейсы элемента DOM с заданным внутренним текстом (доступна с 4.9.34 версии)

Функция на вход принимает параметры:

  • $inner_text – внутренний текст (string).
  • $exactly – точное соответствие внутреннего текста при поиске элементов (boolean), по умолчанию true - внутренний текст элеметов должен полностью совпадать с переданным параметром ($inner_text), если этот параметр задан как false, то будет найдены все элементы во внутреннем тексте которых содержится заданная строка ($inner_text).
  • $include_subchildren – искать также по всем дочерним подэлементам. (доступен с версии 7.0.23)

    После отработки функция возвращает результат своей работы в скрипт :
  • список DOM интерфейсов элементов – объект позволяющий быстро выполнять любые операции со всеми найдеными элементами (по факту массив интерфейсов к DOM элементам позволяющий выполнять вместе все операции, что можно выполнить по отдельности), тип возвращаемого значения XHEInterfaces

    Пример использования
    <?php
    
    // Scenario: For the current page, find a DOM element and get its child DOM elements by text, and get the tag of each child object
    // Description: For the current page, find a DOM element as XHEInterface, and get its child DOM elements by text as XHEInterfaces, and get the tag of each child object
    // Classes used: XHEDiv, XHEBrowser, XHEApplication, XHEInterface, XHEInterfaces
    
    // Connection string to XHE API
    $xhe_host = "localhost:7010";
    
    // Path to init.php file
    if (!isset($path))
    {
        // Path to init.php file for connecting to XHE API
        $path = "../../../Templates/init.php";
        // When connecting the 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 . "anchor.html");
    
    // Example 1: For the current page, find a DOM element as XHEInterface, and get its child DOM elements by text as XHEInterfaces, and get the tag of each child object as an array of strings
    
    // Get the div object by 'name' attribute, as XHEInterface
    $targetDiv = DOM::$div->get_by_name('Name');
    
    // Get child DOM elements from the current div by HTML text, where the text value has an inexact match and the search depth is only the first inheritance level, get the result as a collection object of type XHEInterfaces
    $divChilds = $targetDiv->get_all_child_by_inner_text("Hello",false, false);
    
    // For the collection object of type XHEInterfaces, call the get_tag() method on each element of the collection to get its tag name.
    // As a result of execution, an array of tag name strings for child elements of the current div DOM element will be returned.
    $targetDivChildTags = $divChilds->get_tag();
    
    // Output all tags to the console one by one
    foreach ($targetDivChildTags as $childTag)
        echo($childTag . "\n");
    
    // Stop the application
    WINDOW::$app->quit();
    ?>
    ?>
    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
    
    xhe_host = "127.0.0.1:7025"
    from xweb_human_emulator import *
    
    # начало
    echo("<hr><font color=blue>interface.xxxxxxxxx</font><hr>")
    
    # чтобы быстрее
    browser.set_wait_params(5,1)
    
    # 1 
    echo("1. Перейдем на полигон : ")
    echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/anchor.html"),"<br>")
    
    # 2 
    echo("2. Получим тэги всех элементов в 0 диве по внутренему тексту и его части : \n")
    div0=div.get_by_number(0)
    print(div0.get_all_child_by_inner_text("Hello").get_tag())
    echo("\n")
    print(div0.get_all_child_by_inner_text("e",false).get_tag())
    
    # конец
    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 = "localhost:7010";
    			InitXHE();
    
    			// начало
    			echo("<hr><font color=blue>interface.get_child_by_number</font><hr>");
    							
    			// чтобы быстрее
    			browser.set_wait_params(5,1);
    			
    			// 1 шаг
    			echo("1. Перейдем на полигон : ");
    			echo(browser.navigate("rpa-bot.ru/wiki/poligon/anchor.html")+"<br>");
    			
    			// 2 шаг
    			echo("2. Получим тэги всех элементов в 0 диве по внутренему тексту и его части  : \n");
    			XHEInterface div0=div.get_by_number(0);
    			echo(div0.get_all_child_by_inner_text("Hello").get_tag()+" \n\n");
    			echo(div0.get_all_child_by_inner_text("e",false).get_tag());
    			
    			// конец
    			echo("\n\n");
    
    			app.quit();            
    	  }
    }
    // подключим функциональные объекты, если еще не подключен
    xhe_host="127.0.0.1:7012";
    echo=require("../../../Templates JS/init.js");
    
    // начало
    echo("<hr><font color=blue>interface.get_all_child_by_inner_text</font><hr>");
    
    // чтобы быстрее
    browser.set_wait_params(5,1);
    
    // 1 шаг
    echo("1. Перейдем на полигон : ");
    echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/anchor.html")+"<br>");
    
    // 2 шаг
    echo("2. Получим тэги всех элементов в 0 диве по внутренему тексту и его части : \n\n");
    div0=div.get_by_number(0);
    echo(div0.get_all_child_by_inner_text("Hello").get_tag());
    echo("\n");
    echo(div0.get_all_child_by_inner_text("e",false).get_tag());
    
    // конец
    echo("\n");
    
    // Quit
    app.quit();

    =============================================
    Interface    Объекты    DOM  System  Vision  Web  Window        
    =============================================
    Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.