0

I'm not very good at automation and C# but I'm trying.

My problem is that when a new window opens in the program, and I try to define this element (the window itself), for some reason this does not happen.

The first part of my test runs successfully, yes, there is nothing overly complicated:

 [Test]
    [Order(0)]
    public void OpenPdfWindow()
    {
        
        var desktopElement = desktopSession.DesktopSessionElement;


        WindowsElement DineMain = null;

        while (DineMain == null)
            try
            {

            DineMain = desktopElement.FindElementByAccessibilityId("SetMainWindow");
          
             if (DineMain == null);
            }
            catch
            {
                throw new NoSuchElementException($"Element with AutomationId='{DineMain}' was not found.");
            }
            
            DineMain.Click();

        DineMain.FindElementByAccessibilityId("AdmOpt").Click();
        DineMain.FindElementByAccessibilityId("VIRS").Click();
       ** DineMain.FindElementByAccessibilityId("SPF").Click();**  // <- This is a button, and after clicking, a new window in the program opens.
        Thread.Sleep(10000);
        Assert.Pass();

After that, the second stage follows, where I have problems with "PdfWind" element (window) so this element is not defined (can't be found) for some reason..

public void PdfWindow()
    {
        var desktopElement = desktopSession.DesktopSessionElement;

        WindowsElement PdfWind = null;

        while (PdfWind == null)
            try
            {
             PdfWind = desktopElement.FindElementByAccessibilityId("SetPdfFilesWindow"); <- Here                 
             Thread.Sleep(7000);
                PdfWind.Click();
             if (PdfWind == null) ;
            }
            catch
            {
            throw new NoSuchElementException($"Element with AutomationId='{PdfWind}' was not found.");
            }
        PdfWind.Click();

I do not understand why the element cannot be determined, I'm sure that I specified it correctly.:( enter image description here

I'm sorry, once again - I'm not a professional, I'm just learning, and if I'm doing something wrong, I'll be glad to hear your advice!

Thank you!

To be honest, I tried to define this element (window) in different ways, with different locators, but in the end nothing came of it.

0 Answers0