humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
лог изменений
add_child
add_child($tag,$inner_html); - добавить к элементу дочерний DOM элемент и получить его DOM интерфейс (доступна с 4.9.26 версии)Функция на вход принимает параметры:
После отработки функция возвращает результат своей работы в скрипт :
Пример использования
<?php // Scenario: For the current page, find a DOM element and add a child DOM element to it as HTML code // Description: For the current Browser page, find a DOM element <body> and add a child DOM element anchor to it as HTML code // 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 the body object and add a child DOM element anchor to it as HTML code. // Get the body object by number 0 as XHEInterface $targetBody = DOM::$body->get_by_number(0); // Check that the DOM element is received if ($targetBody->inner_number != -1) { // Add child DOM element anchor as HTML code $targetBody->add_child("a", "<a href=\"http://ya.ru\">yandex.ru</a>"); } // Stop the application WINDOW::$app->quit(); ?>
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7029" 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>") # 3 echo("3. Добавим anchor в body : ") echo(body.get_by_number(0).add_child("div","<link rel=\"stylesheet\" href=\"https://cdn.envybox.io/widget/cbk.css\"><script name=id_call type=\"text/javascript\" src=\"https://cdn.envybox.io/widget/cbk.js?wcb_code=6bfe9d34ab13c02a564921fdf2681511\" charset=\"UTF-8\" async></script>")) echo(body.get_by_number(0).add_child("A","<a href=\"http://ya.ru\">Anchor</a>")) echo(browser.run_java_script("console.log('a');","js\\1.js"),"<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 = "localhost:7010"; InitXHE(); // начало echo("<hr><font color=blue>interface.add_attribute</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("rpa-bot.ru/wiki/poligon/anchor.html")+"\n\n"); // 2 шаг echo("2. Получим объект с именем list : "); XHEInterface obj=anchor.get_by_name("list"); echo(obj.inner_number+"\n\n"); // 3 шаг echo("3. Получим все атрибуты у элемента с именем list : \n\n"); echo(obj.get_all_attributes()+"\n\n"); // 4 шаг echo("4. Добавить id1=value_id1 : "); echo(obj.add_attribute("id1","value_id1")+"\n\n"); // 5 шаг echo("5. Получим все атрибуты у элемента с именем list : \n\n"); echo(obj.get_all_attributes()+"\n\n"); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7010"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>interface.add_child</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. Добавим input в body : "); echo(anchor.get_by_number(0).add_child("input","").is_exist()+"\n"); // 3 шаг echo("3. Добавим anchor в body : "); echo(body.get_by_number(0).add_child("a","new child test anchor").set_attribute("href","http://ya.ru")); // конец echo("\n"); // Quit app.quit();
=============================================
Interface Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.