Esempio n. 1
0
        public void ShouldBeAbleToTellWhetherAWindowExistsOrNotWithinTheSpecifiedAmountOfTime()
        {
            TimeSpan farFarTooLong = TimeSpan.Parse("00:01:00");
            TimeSpan longEnough = TimeSpan.Parse("00:00:05");
            TimeSpan aBitExtraForProcessing = TimeSpan.Parse("00:00:01");

            var started = DateTime.Now;

            Application application = new ApplicationLauncher(farFarTooLong).LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, Assert.Fail);

            bool windowDoesNotExist = false;
            application.FindWindow("Wibble", longEnough, (message) => windowDoesNotExist = true);
            var finished = DateTime.Now;
            var timeBetween = finished.Subtract(started);

            Assert.IsTrue(windowDoesNotExist);
            Assert.LessOrEqual(timeBetween, longEnough.Add(aBitExtraForProcessing));

            windowDoesNotExist = false;
            started = DateTime.Now;
            application.FindWindow(new AndCondition(new PropertyCondition(AutomationElement.NameProperty, "Wibble"),
                                                    new PropertyCondition(AutomationElement.ControlTypeProperty,
                                                                          ControlType.Window)),
                                   longEnough,
                                   message => windowDoesNotExist = true);
            finished = DateTime.Now;
            timeBetween = finished.Subtract(started);

            Assert.IsTrue(windowDoesNotExist);
            Assert.LessOrEqual(timeBetween, longEnough.Add(aBitExtraForProcessing));
        }
Esempio n. 2
0
        public void ShouldBeAbleToTellWhetherAWindowExistsOrNotWithinTheSpecifiedAmountOfTime()
        {
            TimeSpan farFarTooLong          = TimeSpan.Parse("00:01:00");
            TimeSpan longEnough             = TimeSpan.Parse("00:00:05");
            TimeSpan aBitExtraForProcessing = TimeSpan.Parse("00:00:01");

            var started = DateTime.Now;

            Application application = new ApplicationLauncher(farFarTooLong).LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, Assert.Fail);

            bool windowDoesNotExist = false;

            application.FindWindow("Wibble", longEnough, (message) => windowDoesNotExist = true);
            var finished    = DateTime.Now;
            var timeBetween = finished.Subtract(started);

            Assert.IsTrue(windowDoesNotExist);
            Assert.LessOrEqual(timeBetween, longEnough.Add(aBitExtraForProcessing));

            windowDoesNotExist = false;
            started            = DateTime.Now;
            application.FindWindow(new AndCondition(new PropertyCondition(AutomationElement.NameProperty, "Wibble"),
                                                    new PropertyCondition(AutomationElement.ControlTypeProperty,
                                                                          ControlType.Window)),
                                   longEnough,
                                   message => windowDoesNotExist = true);
            finished    = DateTime.Now;
            timeBetween = finished.Subtract(started);

            Assert.IsTrue(windowDoesNotExist);
            Assert.LessOrEqual(timeBetween, longEnough.Add(aBitExtraForProcessing));
        }
Esempio n. 3
0
 public void ShouldFindWindowByCondition()
 {
     Application application = new ApplicationLauncher().LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, Assert.Fail);
     Window window = application.FindWindow(new AndCondition(
                                                FindBy.WpfName("petShopWindow"), FindBy.ControlType(ControlType.Window)));
     Assert.IsNotNull(window.Element);
 }
 public void ShouldAllowUsToLaunchViaALauncher()
 {
     Application application =
         new ApplicationLauncher(TimeSpan.Parse("00:00:10")).LaunchVia(
             EXAMPLE_APP_NAME, "LauncherToOpenAWindowBeforeTheOneWeWant.bat", Assert.Fail);
     application.FindWindow(EXAMPLE_APP_WINDOW_NAME);
 }
Esempio n. 5
0
        public void ShouldFindWindowByName()
        {
            Application application = new ApplicationLauncher().LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, Assert.Fail);
            Window      window      = application.FindWindow("petShopWindow");

            Assert.IsNotNull(window.Element);
        }
Esempio n. 6
0
        public void ShouldFindWindowByCondition()
        {
            Application application = new ApplicationLauncher().LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, Assert.Fail);
            Window      window      = application.FindWindow(new AndCondition(
                                                                 FindBy.WpfName("petShopWindow"), FindBy.ControlType(ControlType.Window)));

            Assert.IsNotNull(window.Element);
        }
        public void ShouldAllowUsToLaunchViaALauncher()
        {
            Application application =
                new ApplicationLauncher(TimeSpan.Parse("00:00:10")).LaunchVia(
                    EXAMPLE_APP_NAME, "LauncherToOpenAWindowBeforeTheOneWeWant.bat", Assert.Fail);

            application.FindWindow(EXAMPLE_APP_WINDOW_NAME);
        }
Esempio n. 8
0
        protected Window LaunchPetShopWindow()
        {
            Application application = new ApplicationLauncher(TimeSpan.Parse("00:00:20"))
                                      .Launch(EXAMPLE_APP_PATH, (s) => Assert.Fail("{0} - {1}", s, EXAMPLE_APP_PATH));

            _window = application.FindWindow(EXAMPLE_APP_WINDOW_NAME);
            _window.HandlerForFailingToFind = Assert.Fail;
            return(_window);
        }
        static void Main(string[] args)
        {
            Application application = new ApplicationLauncher(TimeSpan.Parse("00:00:20"))
                                      .LaunchOrRecycle("foo", @"C:\\hg\\wipflash\\Example.PetShop\\bin\\Debug\\Example.PetShop.exe", Assert.Fail);

            var   window     = application.FindWindow("petShopWindow");
            var   totalLabel = window.Find <Label>("copyPetContextTarget");
            Mouse mouse      = new Mouse();

            mouse.RightClick(totalLabel);
        }
Esempio n. 10
0
        public void ShouldWaitForTheSpecifiedTimeoutAndStopAsSoonAsTheWindowIsFound()
        {
            TimeSpan farFarTooLong = TimeSpan.Parse("00:01:00");
            TimeSpan longEnough    = System.TimeSpan.Parse("00:00:10");


            var started = DateTime.Now;

            Application application = new ApplicationLauncher(farFarTooLong).LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, Assert.Fail);
            Window      window      = application.FindWindow(EXAMPLE_APP_WINDOW_NAME);


            var finished    = DateTime.Now;
            var timeBetween = finished.Subtract(started);

            Assert.LessOrEqual(timeBetween, longEnough);
        }
Esempio n. 11
0
        public void ShouldWaitForTheSpecifiedTimeoutAndStopAsSoonAsTheWindowIsFound()
        {
            TimeSpan farFarTooLong = TimeSpan.Parse("00:01:00");
            TimeSpan longEnough = System.TimeSpan.Parse("00:00:10");

            var started = DateTime.Now;

            Application application = new ApplicationLauncher(farFarTooLong).LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, Assert.Fail);
            Window window = application.FindWindow(EXAMPLE_APP_WINDOW_NAME);

            var finished = DateTime.Now;
            var timeBetween = finished.Subtract(started);

            Assert.LessOrEqual(timeBetween, longEnough);
        }
Esempio n. 12
0
 public void ShouldFindWindowByName()
 {
     Application application = new ApplicationLauncher().LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, Assert.Fail);
     Window window = application.FindWindow("petShopWindow");
     Assert.IsNotNull(window.Element);
 }
Esempio n. 13
0
        public void IsRunning()
        {
            Application application = new ApplicationLauncher(TimeSpan.Parse("00:00:20")).LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, Assert.Fail);

            _universe.Window = application.FindWindow(EXAMPLE_APP_WINDOW_NAME);
        }