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

is_view_now

is_view_now(); - проверить видимость что элемент прямо сейчас виден (находится в видимой части страницы)ю Доступна с версии 4.9.40

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

    Пример использования
    <?php
    
    // Scenario: Check if a DOM element is currently visible in the viewport
    // Description: For current page, find a DOM element and check if it is currently visible in the viewport
    // Classes used: XHEAnchor, 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 init.php file, all functionality of classes for working with XHE API will be available
        require($path);
    }
    
    // Example 1: Check if an element is visible in the viewport
    
    // Navigate to the test site
    echo WEB::$browser->navigate(TEST_SITE_URL);
    
    // Get DOM element <a> by number 0
    $targetAnchor = DOM::$anchor->get_by_number(0);
    
    // Check that the DOM element was found
    if ($targetAnchor->inner_number != -1) {
        // Check if the element is visible in the viewport
        echo $targetAnchor->is_view_now();
    }
    
    echo("\n\n");
    
    // Example 2: Check if anchor 100 is visible and make it visible if not
    
    // Get DOM element <a> by number 100
    $targetAnchor = DOM::$anchor->get_by_number(100);
    
    // Check that the DOM element was found
    if ($targetAnchor->inner_number != -1) {
        // Check if the element is visible in the viewport
        if (!$targetAnchor->is_view_now()) {
            echo "not visible";
        }
        
        // Make the element visible by scrolling to it
        echo $targetAnchor->ensure_visible();
        
        // Check again if the element is visible in the viewport
        echo $targetAnchor->is_view_now();
    }
    
    // Stop the application
    WINDOW::$app->quit();
    ?>
    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
    
    xhe_host = "127.0.0.1:7056"
    from xweb_human_emulator import *
    
    # начало
    echo("<hr><font color=blue>interface.xxxxxxxxx</font><hr>")
    
    # 1 
    echo("1. Перейдем на полигон : ")
    echo(browser.navigate("http://rpa-bot.ru/wiki/"),"<br>")
    
    # 2 
    echo("2. Виден ли с нулевым номером : ")
    echo(anchor.get_by_number(0).is_view_now(),"<br>")
    
    # 3 
    echo("3. Виден ли 100 anchor : ")
    if not anchor.get_by_number(100).is_view_now():
    	echo("не виден<br>")
    
    # 4
    echo("4	. Покажем 100 номер : ")
    echo(anchor.get_by_number(100).ensure_visible(),"\n")
    
    # 5
    echo("5. Виден ли 100 anchor : ")
    echo(anchor.get_by_number(100).is_view_now())
    
    # конец
    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.is_view_now</font><hr>");
    										
    			// 1 шаг
    			echo("1. Перейдем на полигон : ");
    			echo(browser.navigate("https://rpa-bot.ru/wiki")+"<br>");
    			
    			// 2 шаг
    			echo("2. Просматривается ли 0 anchor : ");
    			echo(anchor.get_by_number(0).is_view_now()+"<br>");
    			
    			// 3 шаг
    			echo("3. Просматривается ли 100 anchor : ");
    			if (!anchor.get_by_number(100).is_view_now())
    				echo("не виден<br>");
    
    			// 4 шаг
    			echo("4. Сделаем 100 anchor просмариваемым : ");
    			echo(anchor.get_by_number(100).ensure_visible()+"\n");
    
    			// 5 шаг
    			echo("5. Просматривается ли 100 anchor : ");
    			echo(anchor.get_by_number(100).is_view_now());
    
    			// конец
    			echo("\n\n");
    
    			app.quit();            
    	  }
    }
    // IE + Chrom
    
    // подключим функциональные объекты, если еще не подключен
    xhe_host="127.0.0.1:7056";
    echo=require("../../../Templates JS/init.js");
    
    // начало
    echo("<hr><font color=blue>interface.is_visibled</font><hr>");
    
    // 1 
    echo("1. Перейдем на полигон : ");
    echo(browser.navigate("https://rpa-bot.ru/wiki/")+"<br>");
    
    // 2 
    echo("2. Виден ли с нулевым номером : ");
    echo(anchor.get_by_number(0).is_view_now()+"<br>");
    
    // 3 
    echo("3. Виден ли 100 anchor : ");
    if (!anchor.get_by_number(100).is_view_now())
    	echo("не виден<br>");
    
    // 4
    echo("4	. Покажем 100 номер : ");
    echo(anchor.get_by_number(100).ensure_visible()+"\n");
    	
    // 5
    echo("5. Виден ли 100 anchor : ");
    echo(anchor.get_by_number(100).is_view_now());
    
    // конец
    echo("\n");
    
    // Quit
    app.quit();

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