Selenium WebDriver: Check the Print Window dialog box on the page

I have a script to open the Print Properties dialog box (Windows component) correctly after clicking the Print link. Knowing the class of the Robot utility in Java, which can emulate keyboard events such as Escape / Enter, etc., Run in this window.

Is it possible to check the opening of a new dialog box, this Print dialog box is something to check the title of the title, i.e. Print , or get text from this Windows dialog box or something else else that will confirm the dialog as a Print dialog box .

Print window dialog

+3
source share
2

os, (). . , , java.awt.Robot, VK_ESCAPE , .

:

     Runnable r = new Runnable() {

        @Override
        public void run() {

            try {
                Robot r = new Robot();
                r.delay(1000);
                r.keyPress(KeyEvent.VK_ESCAPE);
                r.keyRelease(KeyEvent.VK_ESCAPE);
            } catch (Exception ex) {
                ex.printStackTrace();
            }

        }
    };

    Actions actions = new Actions(getDriver());
    actions.sendKeys(Keys.CONTROL).sendKeys("p");

    Thread t = new Thread(r);
    t.start();

    actions.perform();

    //some stupid asserts that we reached here
+1

Windows ( ), inspect.exe, . , , . , , , , , . .

 //using System.Windows.Automation;
 //using System.Windows.Forms;

 AutomationElement desktop = AutomationElement.RootElement;
 AutomationElement Firefox = desktop.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ClassNameProperty, "MozillaWindowClass"));
 AutomationElement PrinterComboBox = PrintForm1.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "1139"));
 SelectionPattern selectPrinterComboBox = (SelectionPattern)PrinterComboBox.GetCurrentPattern(SelectionPattern.Pattern);
 AutomationElement ItemInDropdown = PrinterComboBox.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "SelectPrintMethod"));
 SelectionItemPattern ItemInDropdownSelectItem = (SelectionItemPattern)ItemInDropdown.GetCurrentPattern(SelectionItemPattern.Pattern);
 ItemInDropdownSelectItem.Select();
 AutomationElement OKButton = PrintForm1.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, "1"));
 InvokePattern ClickOK = (InvokePattern)OKButton.GetCurrentPattern(InvokePattern.Pattern);
 ClickOK.Invoke();
+1

All Articles