1

I´m triing to install Appium using the WinAppDriver and Visual Studios on my PC. The first Tests are working, but now i´ve got a problem. The tested Program works like this: There is a window opening with a Button, called btnStart. After klicking this button, another window opens. In my Test, there should be a button pressed in the second window called btnC2. The Problem is, that the Tests are working for the first window, but it says that it cant find the btnC2 - i guess because its a nother new window. Do you know how i can fix this? that the test is looking for the btnC2 in the new window?

Thanks a lot!

Here is what the code looks like:

//This one is working     
        [TestMethod]
        public void StartButtonTextTest()
        {
            var startButtonText = session.FindElementByAccessibilityId("btnStart");
            Assert.AreEqual(startButtonText.Text, $"&Start");
            startButtonText.Click();
        }

//This one isn´t
        [TestMethod]
        public void FallWechselButton()
        {
            var fallwechselButton = session.FindElementByAccessibilityId("btnC2");
            Assert.AreEqual(fallwechselButton.Text, $"Fallwechseln");
            fallwechselButton.Click();
            var labelFallText = session.FindElementByAccessibilityId("labelControl1");
            Assert.AreEqual(labelFallText.Text, $"this is a test");
        }


//New Code:
        [TestMethod]
        public void FallWechselButton()
        {
            var startButtonText = session.FindElementByAccessibilityId("btnStart");
            Assert.AreEqual(startButtonText.Text, $"&Start");
            startButtonText.Click();
            var fallwechselButton = session.FindElementByAccessibilityId("cButton2");
            Assert.AreEqual(fallwechselButton.Text, $"Fallwechseln");
            fallwechselButton.Click();
            var labelFallText = session.FindElementByAccessibilityId("labelControl1");
            Assert.AreEqual(labelFallText.Text, $"2000:Paola4 Alvarez3");
        }
S Kirchner
  • 123
  • 12

1 Answers1

0

Ideally you should configure a wait and then check if it loaded.

var wait = new DefaultWait<AndroidDriver<AndroidElement>>(driver)
            {
                Timeout = TimeSpan.FromSeconds(60),
            };

var fallwechselButton  = wait.Until(d => d.FindElementByAccessibilityId("btnC2"));

Also try to capture a screenshot to exactly see if the element was loaded. If, to start with, you do not want to configure a wait, try putting a Thread.Sleep to give some time for the element to load.

shmit
  • 2,306
  • 2
  • 16
  • 20
  • 1
    Hey, Thanks for the answer but it doesnt work. I found out, that i have to put everything in one test - should have been clear because they have to work without each other. The Problem is, that the opening window is not recognized as "session" anymore. – S Kirchner Jul 16 '20 at 07:31