UiPath Documentation
activities
latest
false

Atividades do UIAutomation

Última atualização 8 de mai de 2026

Take Screenshot

Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e a salva em um arquivo.

Essa API deve ser adicionada após Abrir ou Anexar.

Definição

Namespace: UiPath.UIAutomationNext.API.Models

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

Sobrecarregas

SobrecargaDescription
TakeScreenshot(IElementDescriptor, TakeScreenshotOptions)Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e o salva em um arquivo, identificado por um descritor de um elemento do Repositório de Objetos.
TakeScreenshot(IElementDescriptor, String)Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e o salva em um arquivo, identificado por um descritor de um elemento do Repositório de Objetos, especificando o nome do arquivo.
TakeScreenshot(String, TakeScreenshotOptions)Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e o salva em um arquivo, identificado por uma string do Repositório de Objetos, juntamente com outras configurações.
TakeScreenshot(String, String)Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e o salva em um arquivo, identificado por uma string do Repositório de Objetos, juntamente com outras configurações.
TakeScreenshot(RuntimeTarget, TakeScreenshotOptions)Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e o salva em um arquivo, identificado por uma instância de runtime de um elemento do Repositório de Objetos, juntamente com outras configurações.
TakeScreenshot(TargetAnchorableModel, TakeScreenshotOptions)Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e o salva em um arquivo, identificado pelo objeto TargetAnchorableModel , juntamente com outras configurações.
TakeScreenshot(TargetAnchorableModel, String)Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e o salva em um arquivo, identificado pelo objeto TargetAnchorableModel , enquanto especifica o nome do arquivo.

TakeScreenshot(IElementDescriptor, TakeScreenshotOptions)

Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e o salva em um arquivo, identificado por um descritor de um elemento do Repositório de Objetos.

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

elementDescriptor IElementDescriptor : o descritor do elemento do qual se obter a captura de tela. Deixe null para fazer uma captura de tela de toda a área de trabalho.

takeScreenshotOptions TakeScreenshotOptions : opções adicionais para personalizar a captura de tela. Você pode optar por personalizar:

* `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)

Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e o salva em um arquivo, identificado por um descritor de um elemento do Repositório de Objetos, especificando o nome do arquivo.

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

elementDescriptor IElementDescriptor : o descritor do elemento do qual se obter a captura de tela. Deixe null para fazer uma captura de tela de toda a área de trabalho.

fileName String : o nome do arquivo que você deseja salvar.

TakeScreenshot(String, TakeScreenshotOptions)

Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e o salva em um arquivo, identificado por uma string do Repositório de Objetos, juntamente com outras configurações.

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

target String : o destino do qual fazer uma captura de tela, identificado por uma string do Repositório de objetos. Deixe null para fazer uma captura de tela de toda a área de trabalho.

takeScreenshotOptions TakeScreenshotOptions : opções adicionais para personalizar a captura de tela. Você pode optar por personalizar:

* `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)

Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e o salva em um arquivo, identificado por uma string do Repositório de Objetos, juntamente com outras configurações.

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

target String : o destino do qual fazer uma captura de tela, identificado por uma string do Repositório de objetos. Deixe null para fazer uma captura de tela de toda a área de trabalho.

fileName String : o nome do arquivo que você deseja salvar.

TakeScreenshot(RuntimeTarget, TakeScreenshotOptions)

Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e o salva em um arquivo, identificado por uma instância de runtime de um elemento do Repositório de Objetos, juntamente com outras configurações.

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

target RuntimeTarget : o destino do qual se obter uma captura de tela, identificado por uma instância de runtime de um elemento do Repositório de objetos. Deixe null para fazer uma captura de tela de toda a área de trabalho.

takeScreenshotOptions TakeScreenshotOptions : opções adicionais para personalizar a captura de tela. Você pode optar por personalizar:

* `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)

Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e o salva em um arquivo, identificado pelo objeto TargetAnchorableModel , juntamente com outras configurações.

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

target TargetAnchorableModel : o destino do qual fazer uma captura de tela, identificado pelo objeto TargetAnchorableModel . Deixe null para fazer uma captura de tela de toda a área de trabalho.

takeScreenshotOptions TakeScreenshotOptions : opções adicionais para personalizar a captura de tela. Você pode optar por personalizar:

* `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)

Obtém uma captura de tela de um elemento de interface gráfica ou aplicativo especificado e o salva em um arquivo, identificado pelo objeto TargetAnchorableModel , enquanto especifica o nome do arquivo.

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

target TargetAnchorableModel : o destino do qual fazer uma captura de tela, identificado pelo objeto TargetAnchorableModel . Deixe null para fazer uma captura de tela de toda a área de trabalho.

fileName String : o nome do arquivo que você deseja salvar.

Exemplo de código

Aqui está um breve passo a passo de uma implementação de código de exemplo.

Essa linha de código configura o caminho do arquivo onde a captura de tela é salva.

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

Esse comando conecta-se a uma tela de um aplicativo já aberto.

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

A API TakeScreenshot é invocada aqui, capturando a imagem da tela do elemento recém-especificado em sua tela e, posteriormente, salvando-o no caminho do arquivo definido.

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

Verifica se o arquivo de captura de tela existe no filePath fornecido.

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

Por fim, a instrução verifica que o arquivo de captura de tela foi salvo com sucesso no destino filePath.

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

Adição de opções

Você pode adicionar opções em seu código de duas maneiras.

Uma maneira de adicionar opções é usar a sobrecarga correta. Para fazer isso, pressione Ctrl + Space, e IntelliSense aparece, permitindo que você navegue e selecione sua sobrecarga preferida.Você pode decidir selecionar a sobrecarga onde você tem os parâmetros configurados com antecedência. Os parâmetros opcionais são indicados entre colchetes.

Se quiser inicializar uma única configuração como windowResize, você pode usar esta sintaxe:

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

Outra maneira de adicionar opções é usar uma sobrecarga de opção comum, como Attach, e emparelhá-la com a classe Options.Isso oferece um pouco mais de flexibilidade na personalização de seus parâmetros.

Esta página foi útil?

Conectar

Precisa de ajuda? Suporte

Quer aprender? Academia UiPath

Tem perguntas? Fórum do UiPath

Fique por dentro das novidades