humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
Changelog
get_all_by_alt
get_all_by_alt($alt,$exactly=false,$frame="-1"); - Получить все интерфейсы по атрибуту altФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Get all elements by alt attribute from a collection // Description: This example demonstrates how to get a collection of elements and then find all elements with a specific 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 all images with a specific 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 all images with a specific alt (exact match) $targetAlt = "Example Image"; $imagesByAlt = $images->get_all_by_alt($targetAlt, true); // Check if any images with the specified alt were found if ($imagesByAlt->count() > 0) { echo "\nFound " . $imagesByAlt->count() . " image elements with alt '" . $targetAlt . "' (exact match):\n"; // Process each found image for ($k = 0; $k < $imagesByAlt->count(); $k++) { $currentImage = $imagesByAlt->get($k); if ($currentImage && $currentImage->is_exist()) { echo "\nImage #" . ($k + 1) . " with alt '" . $targetAlt . "':\n"; echo "Image src: " . $currentImage->get_src() . "\n"; echo "Image inner number: " . $currentImage->inner_number . "\n"; echo "Image width: " . $currentImage->get_width() . "\n"; echo "Image height: " . $currentImage->get_height() . "\n"; } } } else { echo "\nNo image elements with alt '" . $targetAlt . "' (exact match) found in the collection\n"; } // Try to find all images with a partial alt match $partialAlt = "Example"; $imagesByPartialAlt = $images->get_all_by_alt($partialAlt, false); // Check if any images with the partial alt were found if ($imagesByPartialAlt->count() > 0) { echo "\nFound " . $imagesByPartialAlt->count() . " image elements with partial alt '" . $partialAlt . "':\n"; // Process each found image for ($k = 0; $k < $imagesByPartialAlt->count(); $k++) { $currentImage = $imagesByPartialAlt->get($k); if ($currentImage && $currentImage->is_exist()) { echo "\nImage #" . ($k + 1) . " with partial alt '" . $partialAlt . "':\n"; echo "Image src: " . $currentImage->get_src() . "\n"; echo "Image inner number: " . $currentImage->inner_number . "\n"; echo "Full alt: " . $currentImage->get_alt() . "\n"; } } } else { echo "\nNo image elements with partial alt '" . $partialAlt . "' found in the collection\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. Получим src картинок с alt, содержащим screen : <br>") images_1=images.get_all_by_alt("screen") print(images_1.get_src()) # 4 echo("4. Получим src картинок с alt = screenshot : <br>") images_2=images.get_all_by_alt("screenshot",true) print(images_2.get_src()) # конец 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_all_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. Получим src картинок с alt, содержащим screen : \n\n"); XHEInterfaces images_1=images.get_all_by_alt("screen"); echo(images_1.get_src()); // 4 шаг echo("\n4. Получим src картинок с alt = screenshot : \n\n"); XHEInterfaces images_2=images.get_all_by_alt("screenshot",true); echo(images_2.get_src()); // конец 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_all_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. Получим src картинок с alt, содержащим screen : \n\n"); images_1=images.get_all_by_alt("screen"); echo(images_1.get_src()); // 4 шаг echo("\n4. Получим src картинок с alt = screenshot : \n\n"); images_2=images.get_all_by_alt("screenshot",true); echo(images_2.get_src()); // конец echo("\n"); // Quit app.quit();
=============================================
Interfaces Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.