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

is_exist_by_id

is_exist_by_id($id,$exactly=true,$frame="-1"); - DOM , id

:

  • $id id DOM
  • $exactly ? /
  • $frame , ,

    :
  • true
  • false

    <?php
    // Scenario: Demonstrate the is_exist_by_id function for checking if DOM elements exist by their id attribute
    // Connection settings to XHE server
    $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);
    }
    
    // Navigate to a webpage with elements that have id attributes
    WEB::$browser->navigate(TEST_POLYGON_URL . "anchor.html");
    WEB::$browser->wait_for();
    
    // Example 1: Check if an element exists by its id (existing element)
    echo "Example 1: Checking if an element exists by its id (existing element)\n";
    $elementId = "id1"; // ID of an existing element
    
    // Check if element exists
    $exists = DOM::$anchor->is_exist_by_id($elementId, true);
    
    // Check the result
    if ($exists) {
        echo "Element with id '{$elementId}' exists by id {$elementId}.\n";
    } else {
        echo "Element with id '{$elementId}' does not exist by id {$elementId}.\n";
    }
    
    // Example 2: Check if an element exists in a specific frame by id
    echo "\n\nExample 3: Checking if an element exists in a specific frame by id\n";
    $elementId = "id_f0_mouseover1"; // ID of an element in a frame
    $frameNumber = 0; // First frame
    
    // Check if element exists in frame
    $exists = DOM::$anchor->is_exist_by_id($elementId, false, $frameNumber);
    
    // Check the result
    if ($exists) {
        echo "Element with id '{$elementId}' exists in frame {$frameNumber} by id contains {$elementId}.\n";
    } else {
        echo "Element with id '{$elementId}' does not exist in frame {$frameNumber} by id contains {$elementId}.\n";
    }
    
    
    // Quit 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>common.xxxxxxxxx</font><hr>")
    
    # 1 
    echo("1.    : ")
    echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/anchor.html"),"<br>")
    
    # 2 
    echo("2.      id = seonote_id : ")
    echo(anchor.is_exist_by_id("seonote_id"),"<br>")
    
    # 3
    echo("3.      id ,  seo : ")
    echo(anchor.is_exist_by_id("seo",false),"<br>")
    
    # 4
    echo("4.    : ")
    if not anchor.is_exist_by_id("list_ret211"):
      echo("    <br>")
    
    # 5
    echo("5.      id = list    : ")
    echo(anchor.is_exist_by_id("seonote_id",true,0),"<br>")
    
    # 6
    echo("6.       : ")
    if not anchor.is_exist_by_id("list_ret",true,0):
      echo("    <br>")
    
    # 7
    echo("7.      : ")
    if not anchor.is_exist_by_id("seonote_id",true, 5):
      echo("  <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 = Environment.GetEnvironmentVariable("RPABOT_HOST_URL");
    			InitXHE();
    
    			// 
    			echo("<hr><font color=blue>is_exist_by_name</font><hr>");
    							
    			// 1 
    			echo("1.    : ");
    			echo(browser.navigate("rpa-bot.ru/wiki/poligon/anchor.html")+"<br>");
    			
    			// 2 
    			echo("2.      id = seonote_id : ");
    			echo(anchor.is_exist_by_id("seonote_id")+"<br>");
    			
    			// 3 
    			echo("3.      id ,  seo : ");
    			echo(anchor.is_exist_by_id("seo",false)+"<br>");
    
    			// 4 
    			echo("4.    : ");
    			if(!anchor.is_exist_by_id("list_ret"))
    			  echo("    <br>");
    			
    			// 5 
    			echo("5.       id = is_exist_by_id    : ");
    			echo(anchor.is_exist_by_id("seonote_id",true,"0")+"<br>");
    			
    			// 6 
    			echo("6.       : ");
    			if(!anchor.is_exist_by_id("lidt_ret",true,"0"))
    			  echo("    <br>");
    			
    			// 7 
    			echo("7.      : ");
    			if(!anchor.is_exist_by_id("list",true,"5"))
    			  echo("  <br>");
    
    			// 
    			echo("\n\n");
    
    			app.quit();            
    	  }
    }
    //   ,    
    xhe_host="127.0.0.1:7010";
    echo=require("../../../Templates JS/init.js");
    
    // 
    echo("<hr><font color=blue>anchor.is_exist_by_name</font><hr>");
    
    // 1 
    echo("1.    : ");
    echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/anchor.html")+"<br>");
    
    // 2 
    echo("2.      id = seonote_id : ");
    echo(anchor.is_exist_by_id("seonote_id")+"<br>");
    
    // 3 
    echo("3.      id,  seo : ");
    echo(anchor.is_exist_by_id("seo",false)+"<br>");
    
    // 4 
    echo("4.    : ");
    if(!anchor.is_exist_by_id("list_ret211"))
      echo("    <br>");
    
    // 5 
    echo("5.      id = seonote_id    : ");
    echo(anchor.is_exist_by_id("seonote_id",true,0)+"<br>");
    
    // 6 
    echo("6.       : ");
    if(!anchor.is_exist_by_id("list_ret",true,0))
      echo("    <br>");
    
    // 7 
    echo("7.      : ");
    if(!anchor.is_exist_by_id("seonote_id",true,5))
      echo("  <br>");
    
    // 
    echo("\n");
    
    // Quit
    app.quit();

    =============================================
    a_common        DOM  System  Vision  Web  Window        
    =============================================
    - , .

    PS: DOM, DOM , . DOM.