humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
лог изменений
get_computed_style
get_computed_style($style_name="",$pseudo=""); - Получить вычисляемый стильФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Get computed style of a DOM element // Description: For current page, find a DOM element and get its computed style properties // Classes used: XHEInput, 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); } // Navigate to the polygon page if page was not loaded earlier WEB::$browser->navigate(TEST_POLYGON_URL . "form.html"); // Example 1: Get all computed styles of an element // Get DOM element <input> by number 0 $targetElement = DOM::$input->get_by_number(0); // Check that the DOM element was found if ($targetElement->inner_number != -1) { // Get all computed styles for the found element echo($targetElement->get_computed_style()); } echo("\n\n"); // Example 2: Get specific computed style property // Get DOM element <input> by number 0 $targetElement = DOM::$input->get_by_number(0); // Check that the DOM element was found if ($targetElement->inner_number != -1) { // Get the computed value of the 'background-color' style property echo($targetElement->get_computed_style("background-color")); } echo("\n\n"); // Example 3: Get computed style with pseudo-element // Get DOM element <a> by number 0 $linkElement = DOM::$anchor->get_by_number(0); // Check that the DOM element was found if ($linkElement->inner_number != -1) { // Get the computed value of the 'color' style property for the :hover pseudo-element echo($linkElement->get_computed_style("color", ":hover")); } // Stop the application WINDOW::$app->quit(); ?>
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7013" from xweb_human_emulator import * # начало echo("<hr><font color=blue>interface.xxxxxxxxx</font><hr>") # 1 echo("1. Перейдем на полигон : "); echo(browser.navigate("http://ya.ru"),"<br>"); # 2 echo("2. Получим стиль элемента : "); echo(anchor.get_by_number(2).get_computed_style(),"<br>"); # 3 echo("3. Получим стиль элемента animation : "); echo(anchor.get_by_number(2).get_computed_style("animation"),"<br>"); # 4 echo("4. Получим все стили псевдо элемента ::before : "); echo(anchor.get_by_number(2).get_computed_style("","::before"),"<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.get_inner_html</font><hr>"); // 1 echo("1. Перейдем на полигон : "); echo(browser.navigate("http://ya.ru")+"<br>"); // 2 echo("2. Получим стиль элемента : "); echo(anchor.get_by_number(2).get_computed_style()+"<br>"); // 3 echo("3. Получим стиль элемента animation : "); echo(anchor.get_by_number(2).get_computed_style("animation")+"<br>"); // 4 echo("4. Получим все стили псевдо элемента ::before : "); echo(anchor.get_by_number(2).get_computed_style("","::before")+"<br>"); // конец echo("\n\n"); app.quit(); } }
// IE + Chrom // подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7013"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>interface.get_inner_text</font><hr>"); // 1 echo("1. Перейдем на полигон : "); echo(browser.navigate("http://ya.ru")+"<br>"); // 2 echo("2. Получим стиль элемента : "); echo(anchor.get_by_number(2).get_computed_style()+"<br>"); // 3 echo("3. Получим стиль элемента animation : "); echo(anchor.get_by_number(2).get_computed_style("animation")+"<br>"); // 4 echo("4. Получим все стили псевдо элемента ::before : "); echo(anchor.get_by_number(2).get_computed_style("","::before")+"<br>"); // конец echo("\n"); // Quit app.quit();
=============================================
Interface Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.