UiPath Documentation
activities
latest
false
Important :
Veuillez noter que ce contenu a été localisé en partie à l’aide de la traduction automatique. La localisation du contenu nouvellement publié peut prendre 1 à 2 semaines avant d’être disponible.
UiPath logo, featuring letters U and I in white

Activités UIAutomation

Dernière mise à jour 7 avr. 2026

Prendre une capture d'écran (Take Screenshot)

Prend une capture d'écran d'un élément d'IU ou d'une application spécifié et l'enregistre dans un fichier.

Cette API doit être ajoutée après Ouvrir ou Joindre.

Définition

Espace de noms: UiPath.UIAutomationNext.API.Models

Assembly: UiPath.UIAutomationNext.API.Models (dans UiPath.UIAutomationNext.API.Models dll)

Surcharges

SurchargeDescription
TakeScreenshot(IElementDescriptor, TakeScreenshotOptions)Prend une capture d'écran d'un élément d'IU ou d'une application spécifié et l'enregistre dans un fichier, identifié par un descripteur d'un élément du Référentiel d'objets.
TakeScreenshot(IElementDescriptor, String)Prend une capture d'écran d'un élément ou d'une application d'IU spécifié et l'enregistre dans un fichier, identifié par un descripteur d'un élément du Référentiel d'objets (Object Repository), tout en spécifiant le nom du fichier.
TakeScreenshot(String, TakeScreenshotOptions)Prend une capture d'écran d'un élément ou d'une application d'IU spécifié et l'enregistre dans un fichier, identifié par une chaîne du Référentiel d'objets (Object Repository), ainsi que d'autres configurations.
TakeScreenshot(String, String)Prend une capture d'écran d'un élément ou d'une application d'IU spécifié et l'enregistre dans un fichier, identifié par une chaîne du Référentiel d'objets (Object Repository), ainsi que d'autres configurations.
TakeScreenshot(RuntimeTarget, TakeScreenshotOptions)Prend une capture d'écran d'un élément ou d'une application d'IU spécifié et l'enregistre dans un fichier, identifié par une instance de runtime d'un élément du Référentiel d'objets, ainsi que d'autres configurations.
TakeScreenshot(TargetAnchorableModel, TakeScreenshotOptions)Prend une capture d'écran d'un élément ou d'une application d'IU spécifié et l'enregistre dans un fichier, identifié par l'objet TargetAnchorableModel , avec d'autres configurations.
TakeScreenshot(TargetAnchorableModel, String)Prend une capture d'écran d'un élément d'IU ou d'une application spécifiés et l'enregistre dans un fichier, identifié par l'objet TargetAnchorableModel , tout en spécifiant le nom du fichier.

TakeScreenshot(IElementDescriptor, TakeScreenshotOptions)

Prend une capture d'écran d'un élément d'IU ou d'une application spécifié et l'enregistre dans un fichier, identifié par un descripteur d'un élément du Référentiel d'objets.

TakeScreenhot(
    IElementDescriptor elementDescriptor,
    TakeScreenshotOptions takeScreenshotOptions)
TakeScreenhot(
    IElementDescriptor elementDescriptor,
    TakeScreenshotOptions takeScreenshotOptions)

elementDescriptor IElementDescriptor : le descripteur d'élément à partir duquel prendre la capture d'écran. Laissez null pour prendre une capture d'écran de tout le bureau.

takeScreenshotOptions TakeScreenshotOptions : options supplémentaires pour personnaliser la capture d'écran. Vous pouvez choisir de personnaliser :

* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in
    seconds) to wait for the API to run before the
    `SelectorNotFoundException` error is
    thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after
    executing the API. The default amount of time is 0.3 seconds
    (300 milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the
    API begins performing any operations. The default amount of
    time is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to
  save.
* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in
    seconds) to wait for the API to run before the
    `SelectorNotFoundException` error is
    thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after
    executing the API. The default amount of time is 0.3 seconds
    (300 milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the
    API begins performing any operations. The default amount of
    time is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to
  save.

TakeScreenshot(IElementDescriptor, String)

Prend une capture d'écran d'un élément ou d'une application d'IU spécifié et l'enregistre dans un fichier, identifié par un descripteur d'un élément du Référentiel d'objets (Object Repository), tout en spécifiant le nom du fichier.

TakeScreenhot(
    IElementDescriptor elementDescriptor,
    string fileName)
TakeScreenhot(
    IElementDescriptor elementDescriptor,
    string fileName)

elementDescriptor IElementDescriptor : le descripteur d'élément à partir duquel prendre la capture d'écran. Laissez null pour prendre une capture d'écran de tout le bureau.

fileName String : le nom du fichier que vous souhaitez enregistrer.

TakeScreenshot(String, TakeScreenshotOptions)

Prend une capture d'écran d'un élément ou d'une application d'IU spécifié et l'enregistre dans un fichier, identifié par une chaîne du Référentiel d'objets (Object Repository), ainsi que d'autres configurations.

TakeScreenhot(
    string target,
    TakeScreenshotOptions takeScreenshotOptions)
TakeScreenhot(
    string target,
    TakeScreenshotOptions takeScreenshotOptions)

target String : la cible à partir de laquelle prendre une capture d'écran, identifiée par une chaîne du référentiel d'objets. Laissez null pour prendre une capture d'écran de tout le bureau.

takeScreenshotOptions TakeScreenshotOptions : options supplémentaires pour personnaliser la capture d'écran. Vous pouvez choisir de personnaliser :

* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in seconds)
    to wait for the API to run before the
    `SelectorNotFoundException` error is
    thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after executing
    the API. The default amount of time is 0.3 seconds (300
    milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the API
    begins performing any operations. The default amount of time
    is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to
  save.
* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in seconds)
    to wait for the API to run before the
    `SelectorNotFoundException` error is
    thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after executing
    the API. The default amount of time is 0.3 seconds (300
    milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the API
    begins performing any operations. The default amount of time
    is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to
  save.

TakeScreenshot(String, String)

Prend une capture d'écran d'un élément ou d'une application d'IU spécifié et l'enregistre dans un fichier, identifié par une chaîne du Référentiel d'objets (Object Repository), ainsi que d'autres configurations.

TakeScreenhot(
    string target,
    string fileName)
TakeScreenhot(
    string target,
    string fileName)

target String : la cible à partir de laquelle prendre une capture d'écran, identifiée par une chaîne du référentiel d'objets. Laissez null pour prendre une capture d'écran de tout le bureau.

fileName String : le nom du fichier que vous souhaitez enregistrer.

TakeScreenshot(RuntimeTarget, TakeScreenshotOptions)

Prend une capture d'écran d'un élément ou d'une application d'IU spécifié et l'enregistre dans un fichier, identifié par une instance de runtime d'un élément du Référentiel d'objets, ainsi que d'autres configurations.

TakeScreenhot(
    RuntimeTarget target,
    TakeScreenshotOptions takeScreenshotOptions)
TakeScreenhot(
    RuntimeTarget target,
    TakeScreenshotOptions takeScreenshotOptions)

target RuntimeTarget : la cible à partir de laquelle prendre une capture d'écran, identifiée par une instance de runtime d'un élément du référentiel d'objets. Laissez null pour prendre une capture d'écran de tout le bureau.

takeScreenshotOptions TakeScreenshotOptions : options supplémentaires pour personnaliser la capture d'écran. Vous pouvez choisir de personnaliser :

* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in seconds)
    to wait for the API to run before the
    `SelectorNotFoundException` error is
    thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after executing
    the API. The default amount of time is 0.3 seconds (300
    milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the API
    begins performing any operations. The default amount of time
    is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to
  save.
* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in seconds)
    to wait for the API to run before the
    `SelectorNotFoundException` error is
    thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after executing
    the API. The default amount of time is 0.3 seconds (300
    milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the API
    begins performing any operations. The default amount of time
    is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to
  save.

TakeScreenshot(TargetAnchorableModel, TakeScreenshotOptions)

Prend une capture d'écran d'un élément ou d'une application d'IU spécifié et l'enregistre dans un fichier, identifié par l'objet TargetAnchorableModel , avec d'autres configurations.

TakeScreenhot(
    TargetAnchorableModel target,
    TakeScreenshotOptions takeScreenshotOptions)
TakeScreenhot(
    TargetAnchorableModel target,
    TakeScreenshotOptions takeScreenshotOptions)

target TargetAnchorableModel : la cible à partir de laquelle prendre une capture d'écran, identifiée par l'objet TargetAnchorableModel . Laissez null pour prendre une capture d'écran de tout le bureau.

takeScreenshotOptions TakeScreenshotOptions : options supplémentaires pour personnaliser la capture d'écran. Vous pouvez choisir de personnaliser :

* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in seconds)
    to wait for the API to run before the
    `SelectorNotFoundException` error is
    thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after executing
    the API. The default amount of time is 0.3 seconds (300
    milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the API
    begins performing any operations. The default amount of time
    is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to
  save.
* `TargetOptions`:
  + **Timeout** - Specifies the amount of time (in seconds)
    to wait for the API to run before the
    `SelectorNotFoundException` error is
    thrown. The default value is 30 seconds.
  + **DelayAfter** - Delay time (in seconds) after executing
    the API. The default amount of time is 0.3 seconds (300
    milliseconds).
  + **DelayBefore** - Delay time (in seconds) before the API
    begins performing any operations. The default amount of time
    is 0.2 seconds (200 milliseconds).
* `FileName` - The name of the file you want to
  save.

TakeScreenshot(TargetAnchorableModel, String)

Prend une capture d'écran d'un élément d'IU ou d'une application spécifiés et l'enregistre dans un fichier, identifié par l'objet TargetAnchorableModel , tout en spécifiant le nom du fichier.

TakeScreenhot(
    TargetAnchorableModel target, 
    string fileName)
TakeScreenhot(
    TargetAnchorableModel target, 
    string fileName)

target TargetAnchorableModel : la cible à partir de laquelle prendre une capture d'écran, identifiée par l'objet TargetAnchorableModel . Laissez null pour prendre une capture d'écran de tout le bureau.

fileName String : le nom du fichier que vous souhaitez enregistrer.

Exemple de code

Voici un bref aperçu d’un exemple d’implémentation de code.

Cette ligne de code définit le chemin d’accès au fichier dans lequel la capture d’écran est enregistrée.

var filePath = "C:\\samplefile.jpg";
var filePath = "C:\\samplefile.jpg";

Cette commande se connecte à un écran à partir d’une application déjà ouverte.

var sampleApp = uiAutomation.Attach(Descriptors.NewApplication.NewScreen);
var sampleApp = uiAutomation.Attach(Descriptors.NewApplication.NewScreen);

L’API TakeScreenshot est invoquée à cet endroit, capturant la capture d’écran du nouvel élément spécifié sur votre écran et l’enregistrant par la suite dans le chemin d’accès défini.

sampleApp.TakeScreenshot(Descriptors.NewApplication.NewScreen.NewElement, filePath);
sampleApp.TakeScreenshot(Descriptors.NewApplication.NewScreen.NewElement, filePath);

Vérifie si le fichier de capture d’écran existe au niveau du filePath donné.

var fileExists = system.FileExists(filePath);
var fileExists = system.FileExists(filePath);

Enfin, l’instruction vérifie que le fichier de capture d’écran est enregistré dans le filePath cible.

testing.VerifyAreEqual(fileExists, true);
testing.VerifyAreEqual(fileExists, true);

Ajout d’options

Vous pouvez ajouter des options à votre code de deux manières.

Vous pouvez notamment utiliser la surcharge appropriée. Pour ce faire, appuyez sur Ctrl + Space pour faire apparaître IntelliSense, vous permettant de parcourir et de sélectionner votre surcharge préférée. Vous pouvez décider de sélectionner la surcharge dans laquelle les paramètres sont déjà configurés. Les paramètres facultatifs sont indiqués entre parenthèses.

Si vous souhaitez initialiser un seul paramètre comme windowResize, vous pouvez utiliser la syntaxe suivante :

var sampleApp = uiAutomation.Attach(Descriptors.NewApplication.NewScreen, windowResize: NWindowResize.Restore);
var sampleApp = uiAutomation.Attach(Descriptors.NewApplication.NewScreen, windowResize: NWindowResize.Restore);

Pour ajouter des options, vous pouvez également utiliser une surcharge d’options courantes, telle que Joindre (Attach), et l’associer à la classe Options. Cette action vous offre un peu plus de flexibilité dans la personnalisation de vos paramètres.

Cette page vous a-t-elle été utile ?

Connecter

Besoin d'aide ? Assistance

Vous souhaitez apprendre ? UiPath Academy

Vous avez des questions ? UiPath Forum

Rester à jour