humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
Changelog
get_by_alt
get_by_alt($alt,$exactly=true); - Получить интерфейс по атрибуту altФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Get elements by alt attribute from a collection // Description: This example demonstrates how to get a collection of elements and then find specific elements by their alt attribute within that collection // Classes used: XHEInterfaces, XHEImage, XHEBrowser, XHEApplication // Connection string to XHE API $xhe_host = getenv("RPABOT_HOST_URL"); // 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 the page was not loaded earlier WEB::$browser->navigate(TEST_POLYGON_URL . "images.html"); // Example: Get all image elements and then find specific images by their alt attribute within that collection // Get all image elements on the page $images = DOM::$image->get_all(); // Check that we have found at least one image if ($images->count() > 0) { echo "Found " . $images->count() . " image elements\n"; // Try to find an image with a specific alt (exact match) in image elements $targetAlt = "Example Image"; $imageByAlt = $images->get_by_alt($targetAlt, true); // Check if the image with the specified alt was found if ($imageByAlt && $imageByAlt->is_exist()) { echo "\nFound image with alt '" . $targetAlt . "' (exact match):\n"; echo "Image src: " . $imageByAlt->get_src() . "\n"; echo "Image inner number: " . $imageByAlt->inner_number . "\n"; echo "Image width: " . $imageByAlt->get_width() . "\n"; echo "Image height: " . $imageByAlt->get_height() . "\n"; } else { echo "\nNo image with alt '" . $targetAlt . "' (exact match) found in the collection\n"; } // Try to find an image with a partial alt match in image elements $partialAlt = "Example"; $imageByPartialAlt = $images->get_by_alt($partialAlt, false); // Check if the image with the partial alt was found if ($imageByPartialAlt && $imageByPartialAlt->is_exist()) { echo "\nFound image with partial alt '" . $partialAlt . "':\n"; echo "Image src: " . $imageByPartialAlt->get_src() . "\n"; echo "Image inner number: " . $imageByPartialAlt->inner_number . "\n"; echo "Full alt: " . $imageByPartialAlt->get_alt() . "\n"; // Get the parent element of the found image $parentElement = $imageByPartialAlt->get_parent(); if ($parentElement->is_exist()) { echo "Parent element exists\n"; } } else { echo "\nNo image with partial alt '" . $partialAlt . "' found in the collection\n"; } } else { echo "No image elements found on the page\n"; } // 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>interfaces.xxxxxxxxx</font><hr>") # 1 echo("1. Перейдем на полигон : ") echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/image.html"),"<br>") # 2 echo("2. Получить все рисунки : ") images=image.get_all() echo(images.get_count(),"<br>") # 3 echo("3. Получим размеры картинки с alt = screenshot : ") img_01=images.get_by_alt("screenshot") echo(img_01.get_width()," x ") echo(img_01.get_height(),"<br>") # 4 echo("4. Получим размеры картинки с alt, содержащей shot 1 : ") img_02=images.get_by_alt("shot 1",false) echo(img_02.get_width()," x ") echo(img_02.get_height(),"<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 = Environment.GetEnvironmentVariable("RPABOT_HOST_URL"); InitXHE(); // начало echo("<hr><font color=blue>interfaces.get_by_alt</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("rpa-bot.ru/wiki/poligon/image.html")+"<br>"); // 2 шаг echo("2. Получить все рисунки : "); XHEInterfaces images=image.get_all(); echo(images.get_count()+"<br>"); // 3 шаг echo("3. Получим размеры картинки с alt = screenshot : "); XHEInterface img_01=images.get_by_alt("screenshot"); echo(img_01.get_width()+"x"+img_01.get_height()+"<br>"); // 4 шаг echo("4. Получим размеры картинки с alt, содержащей shot 1 : "); XHEInterface img_02=images.get_by_alt("shot 1",false); echo(img_02.get_width()+"x"+img_02.get_height()+"<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_by_alt</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/image.html")+"<br>"); // 2 шаг echo("2. Получить все рисунки : "); images=image.get_all(); echo(images.get_count()+"<br>"); // 3 шаг echo("3. Получим размеры картинки с alt = screenshot : "); img_01=images.get_by_alt("screenshot"); echo(img_01.get_width()+" x "+img_01.get_height()+"<br>"); // 4 шаг echo("4. Получим размеры картинки с alt, содержащей shot 1 : "); img_02=images.get_by_alt("shot 1",false); echo(img_02.get_width()+" x "+img_02.get_height()+"<br>"); // конец echo("\n"); // Quit app.quit();
=============================================
Interfaces Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.