Print window, save PDF Selenium Webdriver

Asked

Viewed 1,102 times

7

After developing a web page, I am developing the automated testing of this one. I am using Selenium Webdriver com for . NET.

After clicking the print button, the popup to choose the printer or change to PDF is displayed, with this my test to, it returns to run soon after print/save the document or cancel the operation. Is there any way to manipulate this popup/window.

I refer to this popup/window: inserir a descrição da imagem aqui

  • 1

    The print preview screen is outside the limits of Selenium, so only with it I believe it will not be possible, an alternative is to combine the use with some tool like Sikuli or Autoit that are not limited to the browser only.

  • Thank you @Lucasmiranda!

1 answer

0


For windows or windows form, you need to use another framework like Uiautomationclient,

see examples below.

var processoId = Process.GetProcessesByName(Nome do processo).First().Id;               
AutomationElement rootElement  = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ProcessIdProperty, processId));

var botaoSalva = rootElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ClassNameProperty, "Nome da propriedade do botão salva"));

object obj;

if (botaoSalva.TryGetCurrentPattern(InvokePattern.Pattern, out obj))
{
    InvokePattern invoker = obj as InvokePattern;

    invoker.Invoke();
}

There are tools like Inspect and the Uiaverify which allows you to see the properties of each field of the dialog to get the name of the properties.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.