humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
лог изменений
get_parent
get_parent($level=1); - получить интерфейс родительского элемента DOM (доступна с 4.6.41 версии)Функция на вход принимает параметры:
После отработки функция возвращает результат своей работы в скрипт :
Пример использования
<?php // Scenario: For current page, find a DOM element and get its parent element // Description: For the current page, find a DOM element and get its parent element in the DOM tree // 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 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 . "anchor.html"); // Example 1: Get tags and numbers of parent elements // Get the anchor object by 'name' attribute, as XHEInterface $targetAnchor = DOM::$anchor->get_by_name("seonote"); // Check that the DOM element is received if ($targetAnchor->inner_number != -1) { // Get the first parent element $parent1 = $targetAnchor->get_parent(); // Get the second parent element $parent2 = $parent1->get_parent(); // Get the third parent element $parent3 = $parent2->get_parent(); // Check that the parent elements are received if ($parent1->inner_number != -1 && $parent2->inner_number != -1 && $parent3->inner_number != -1) { // Get tags and numbers of parent elements echo($parent1->get_tag() . " " . $parent1->get_number() . " "); echo($parent2->get_tag() . " " . $parent2->get_number() . " "); echo($parent3->get_tag() . " " . $parent3->get_number() . "\n"); } } // Example 2: Get tag and number of parent element with level 3 // Get the anchor object by 'name' attribute, as XHEInterface $targetAnchor = DOM::$anchor->get_by_name("seonote"); // Check that the DOM element is received if ($targetAnchor->inner_number != -1) { // Get the parent element at level 3 $parentLevel3 = $targetAnchor->get_parent(3); // Check that the parent element is received if ($parentLevel3->inner_number != -1) { // Get tag and number of parent element echo($parentLevel3->get_tag() . " " . $parentLevel3->get_number() . "\n"); } } // Stop the application WINDOW::$app->quit(); ?>
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:701" 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. Получим тэги и номера родительских элементов : ") obj_a=anchor.get_by_name("seonote") obj_p=obj_a.get_parent() obj_b=obj_p.get_parent() obj_h=obj_b.get_parent() echo(obj_p.get_tag()," ") echo(obj_b.get_tag()," ") echo(obj_h.get_tag()," : ") echo(obj_p.get_number()," ") echo(obj_b.get_number()," ") echo(obj_h.get_number(),"\n") # 3 echo("3. Получим тэги родительского элемента уровня 3 : ") obj_p=obj_a.get_parent(3) echo(obj_p.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_parent</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. Получим тэги и номера родительских элементов : "); XHEInterface obj_a=anchor.get_by_name("seonote"); XHEInterface obj_p=obj_a.get_parent(); XHEInterface obj_b=obj_p.get_parent(); XHEInterface obj_h=obj_b.get_parent(); echo(obj_p.get_tag()+" "+obj_b.get_tag()+" "+obj_h.get_tag()+" : "); echo(obj_p.get_number()+" "+obj_b.get_number()+" "+obj_h.get_number()+"\n"); // 3 шаг echo("3. Получим тэг родительского элемента с уронем 3 : "); obj_p=obj_a.get_parent(3); echo(obj_p.get_tag()); // конец echo("\n\n"); app.quit(); } }
// IE + Chrom // подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:701"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>interface.get_parent</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. Получим тэги и номера родительских элементов : "); obj_a=anchor.get_by_name("seonote"); obj_p=obj_a.get_parent(); obj_b=obj_p.get_parent(); obj_h=obj_b.get_parent(); echo(obj_p.get_tag()+" "+obj_b.get_tag()+" "+obj_h.get_tag()+" : "); echo(obj_p.get_number()+" "+obj_b.get_number()+" "+obj_h.get_number()+"\n"); // 3 шаг echo("3. Получим тэг родительского элементов уровня 3: "); obj_p=obj_a.get_parent(3); echo(obj_p.get_tag()+" "); echo(obj_p.get_number()+"\n"); // конец echo("\n"); // Quit app.quit();
=============================================
Interface Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.