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

get_all_by_inner_text

get_all_by_inner_text($inner_text,$exactly=false,$frame="-1"); - Получить все интерфейсы по внутреннему тексту

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

  • $inner_text – значение внутреннего текста
  • $exactly – Требуется точное соответствие значения? Да/Нет

    После выполнения функции возвращаемое значение будет равно одному из двух :
  • число (интерфейсы)
  • -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("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 ссылок с html, содержащим ссылка : <br>")
    anchors_1=anchors.get_all_by_inner_text("ссылка")
    print(anchors_1.get_href())
    
    # 4 
    echo("4. Получим href ссылок с html = Блог : <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 = Environment.GetEnvironmentVariable("RPABOT_HOST_URL");
    			InitXHE();
    
    			// начало
    			echo("<hr><font color=blue>interfaces.get_all_by_inner_text</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_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("\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_inner_text</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 ссылок с html, содержащим ссылка : \n\n");
    anchors_1=anchors.get_all_by_inner_text("ссылка");
    echo(anchors_1.get_href());
    
    // 4 шаг
    echo("\n4. Получим href ссылок с html = Блог :\n\n");
    anchors_2=anchors.get_all_by_inner_text("Блог",true);
    echo(anchors_2.get_href());
    
    // конец
    echo("\n");
    
    // Quit
    app.quit();

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