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

get_child_by_inner_html

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

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

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

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

    Пример использования
    <?php
    
    // Scenario: For the current page, find a DOM element and get a child DOM element by inner HTML value
    // Description: For the current page, find 0 DOM element <form> and get its child DOM element by inner HTML value
    // Classes used: XHEForm, XHEInterface, XHEBrowser, XHEApplication
    
    // 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 . "form.html");
    
    // Example 1: For the current page, get 0 DOM element <form> and get its first child DOM element by inner HTML value, search at the first level of the tree
    
    // Get DOM element <form> by number 0
    $targetForm = DOM::$form->get_by_number(0);
    
    // Get the first found child DOM element by inner HTML value as XHEInterface, exact match of value, search for descendant at the first level of the tree
    $targetFormChild = $targetForm->get_child_by_inner_html("ссылка onmouseover",false,false);
    
    // Check that the DOM element is received
    if ($targetFormChild->inner_number != -1) {
        // Call the get_tag() method for the element to get its tag name.
        $targetFormChild->get_tag();
    }
    
    // Example 2: For the current page, get 0 DOM element <form> and get its first child DOM element by inner HTML value, search for descendant at any level of the tree
    
    // Get DOM element <form> by number 0
    $targetForm = DOM::$form->get_by_number(0);
    
    // Get the first found child DOM element by inner HTML value as XHEInterface, exact match of value, search for descendant at the first level of the tree
    $targetFormChild = $targetForm->get_child_by_inner_html("ссылка onmouseover",true,true);
    
    // Check that the DOM element is received
    if ($targetFormChild->inner_number != -1) {
        // Call the get_tag() method for the element to get its tag name.
        $targetFormChild->get_tag();
    }
    
    
    // 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>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 диве по внутренему html и его части : ")
    div0=div.get_by_number(0)
    echo(div0.get_child_by_inner_html("Hello").get_tag()," ")
    echo(div0.get_child_by_inner_html("G",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 диве по внутренему html и его части : ");
    			XHEInterface div0=div.get_by_number(0);
    			echo(div0.get_child_by_inner_html("Hello").get_tag()+" ");
    			echo(div0.get_child_by_inner_html("G",0).get_tag());
    			
    			// конец
    			echo("\n\n");
    
    			app.quit();            
    	  }
    }
    // IE + Chrom
    
    // подключим функциональные объекты, если еще не подключен
    xhe_host="127.0.0.1:7012";
    echo=require("../../../Templates JS/init.js");
    
    // начало
    echo("<hr><font color=blue>interface.get_child_by_inner_html</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 диве по внутренему html и его части : ");
    div0=div.get_by_number(0);
    echo(div0.get_child_by_inner_html("Hello").get_tag()+" ");
    echo(div0.get_child_by_inner_html("G",false).get_tag());
    
    // конец
    echo("\n");
    
    // Quit
    app.quit();

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