humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
лог изменений
get_y
get_y($in_view=false); - получить Y координату левого верхнего угла элемента в DOM модели, относительно левого верхнего угла браузераФункция на вход принимает параметры:
После отработки функция возвращает результат своей работы в скрипт :
Пример использования
<?php // Scenario: Get Y coordinate of a DOM element // Description: For current page, find a DOM element and get its Y coordinate relative to the page // 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: Get Y coordinate of link by href attribute // Navigate to the polygon page echo WEB::$browser->navigate(TEST_POLYGON_URL . "anchor.html"); // Get DOM element <a> by href attribute $targetAnchor = DOM::$anchor->get_by_attribute("href", TEST_SITE_URL); // Check that the DOM element was found if ($targetAnchor->inner_number != -1) { // Get Y coordinate of the found element echo $targetAnchor->get_y(); } echo("\n\n"); // Example 2: Get Y coordinate (in visible part of page) of link // Navigate to the test site echo WEB::$browser->navigate(TEST_SITE_URL); // Get DOM element <a> by number 110 $targetAnchor = DOM::$anchor->get_by_number(110); // Check that the DOM element was found if ($targetAnchor->inner_number != -1) { // Set focus to the element $targetAnchor->focus(); // Get Y coordinate of the element relative to the visible part of the page echo $targetAnchor->get_y(true); } echo("\n\n"); // Example 3: Get Y coordinate of link (on page) // Get DOM element <a> by number 110 $targetAnchor = DOM::$anchor->get_by_number(110); // Check that the DOM element was found if ($targetAnchor->inner_number != -1) { // Get Y coordinate of the element relative to the page echo $targetAnchor->get_y(); } // Stop 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>interface.xxxxxxxxx</font><hr>") # 1 echo("1. Перейдем на полигон : ") echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/anchor.html"),"<br>") # 2 echo("2. По полному урлу : ") echo(anchor.get_by_attribute("href","https://rpa-bot.ru/wiki/").get_y(),"<br>") # 3 echo("3. Перейдем на полигон : "); echo(browser.navigate("http://rpa-bot.ru/wiki/"),"<br>"); # 4 echo("4. Получим x у (в видимой части страницы) ссылки : "); anchor.get_by_number(110).focus(); echo(anchor.get_by_number(110).get_y(True),"\n"); # 5 echo("5. Получим у ссылки (на странице): "); echo(anchor.get_by_number(110).get_y(),"<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_y</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("rpa-bot.ru/wiki/poligon/anchor.html")+"<br>"); // 2 шаг echo("2. По полному урлу : "); echo(anchor.get_by_attribute("href","http://rpa-bot.ru/wiki/").get_y()+"<br>"); // 3 echo("3. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki")+"<br>"); // 4 echo("4. Получим x у (в видимой части страницы) ссылки : "); anchor.get_by_number(110).focus(); echo(anchor.get_by_number(110).get_y(true)+"\n"); // 5 echo("5. Получим у ссылки (на странице): "); echo(anchor.get_by_number(110).get_y()+"<br>"); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7010"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>interface.get_y</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/anchor.html")+"<br>"); // 2 шаг echo("2. По полному урлу : "); echo(anchor.get_by_attribute("href","https://rpa-bot.ru/wiki/").get_y()+"<br>"); // 3 echo("3. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki/")+"<br>"); // 4 echo("4. Получим x у (в видимой части страницы) ссылки : "); anchor.get_by_number(110).focus(); echo(anchor.get_by_number(110).get_y(true)+"\n"); // 5 echo("5. Получим у ссылки (на странице): "); echo(anchor.get_by_number(110).get_y()+"<br>"); // конец echo("\n"); // Quit app.quit();
=============================================
Interface Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.