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