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

is_equal

is_equal($ui); - Сравнить UI элементы на равенство

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

  • $ui – UI элемент для сравнения

    После выполнения функции возвращаемое значение будет равно одному из двух :
  • true – успешно
  • false – не удалось

    Пример использования
    <?php
    // Scenario: Demonstrates how to compare two UI elements for equality
    
    $xhe_host = getenv("RPABOT_HOST_URL");
    if (!isset($path)){
        // Path to the init.php file for connecting to the XHE API
        $path = "../../../Templates/init.php";
        // Including init.php grants access to all classes and functionality for working with the XHE API
        require($path);
    }
    
    // Step: Get UI element for interaction
    $windowText = "localhost";
    $xheElement1 = WINDOW::$window->get_by_text($windowText)->get_ui_element();
    
    // Step: Get the next element and then the previous element (should return to original)
    $xheElement2 = $xheElement1->get_prev()->get_next();
    
    // Example 1: Compare element with its previous->next (should be equal)
    $isEqual1 = $xheElement1->is_equal($xheElement2);
    
    if ($isEqual1) {
        echo("Example 1: Elements are equal (as expected)\n");
    } else {
        echo("Example 1: Elements are not equal (unexpected)\n");
    }
    
    // Step: Get the previous element of the second element
    $xheElement3 = $xheElement2->get_prev();
    
    // Example 2: Compare element with previous element of the second element (should not be equal)
    $isEqual2 = $xheElement1->is_equal($xheElement3);
    
    if ($isEqual2) {
        echo("Example 2: Elements are equal (unexpected)\n");
    } else {
        echo("Example 2: Elements are not equal (as expected)\n");
    }
    
    // Quit 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>ui.xxxxxxxxx</font><hr>")
    
    # 1 
    echo("1. Сравнить на равенство : ")
    xhe1=window.get_by_text("localhost").get_ui_element()
    xhe2=xhe1.get_next().get_prev()
    echo(xhe1.is_equal(xhe2))
    echo(xhe1.is_equal(xhe2.get_prev()))
    
    # конец
    echo("<hr><br>")
    
    # уведомляем среду что скрипт закончил работать
    echo(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>windowinterface.set_text</font><hr>");
    				
    			// 1 
    			echo("1. Сравним элементы на равенство : ");
    			var xhe1=window.get_by_text("localhost").get_ui_element();
    			var xhe2=xhe1.get_next().get_prev();
    			echo(xhe1.is_equal(xhe2));
    			echo(xhe1.is_equal(xhe2.get_prev()));
    
    			// конец
    			echo("\n\n");
    
    			app.quit();            
    	  }
    }
    // подключим функциональные объекты, если еще не подключен
    xhe_host="127.0.0.1:7025";
    echo=require("../../../Templates JS/init.js");
    
    // начало
    echo("<hr><font color=blue>ui.xxx</font><hr>");
    
    // 1 
    echo("1. Сравнить элементы на равенство : ");
    var xhe1=window.get_by_text("localhost").get_ui_element();
    var xhe2=xhe1.get_prev().get_next();
    echo(xhe1.is_equal(xhe2));
    echo(xhe1.is_equal(xhe2.get_prev()));
    
    // конец
    echo("\n");
    
    // уведомляем среду что скрипт закончил работать
    echo(app.quit());

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