Beispiel #1
0
        public static void Setup(TestContext context)
        {
            // Launch Edge browser app if it is not yet launched
            if (session == null || touchScreen == null || !Utility.CurrentWindowIsAlive(session))
            {
                // Cleanup leftover objects from previous test if exists
                TearDown();

                // Launch the Edge browser app
                session = Utility.CreateNewSession(CommonTestSettings.EdgeAppId, "-private");
                session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
                Assert.IsNotNull(session);
                Assert.IsNotNull(session.SessionId);

                // Initialize touch screen object
                touchScreen = new RemoteTouchScreen(session);
                Assert.IsNotNull(touchScreen);
            }

            // Track the Microsoft Edge starting page title to be used to initialize all test cases
            Thread.Sleep(TimeSpan.FromSeconds(1));
            startingPageTitle = session.Title;

            // Handle Microsoft Edge restored state by starting fresh
            if (startingPageTitle.StartsWith("Start fresh and "))
            {
                try
                {
                    session.FindElementByXPath("//Button[@Name='Start fresh']").Click();
                    Thread.Sleep(TimeSpan.FromSeconds(3));
                    startingPageTitle = session.Title;
                }
                catch { }
            }
        }
Beispiel #2
0
        public static void Setup(TestContext context)
        {
            // Uruchom aplikację jeżeli jeszcze nie została uruchomiona
            if (session == null || touchScreen == null)
            {
                TearDown();

                //Tworzenie sesji

                Process.Start(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe");

                AppiumOptions options = new AppiumOptions();
                options.AddAdditionalCapability("deviceName", "WindowsPC");
                options.AddAdditionalCapability("platformName", "Windows");
                options.AddAdditionalCapability("app", "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App");

                session = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), options);

                Assert.IsNotNull(session);
                Assert.IsNotNull(session.SessionId);
                Assert.AreEqual("Alarmy i zegar", session.FindElementByName("Alarmy i zegar").Text);

                // Ustawienie domyślnego limitu czasu na 1.5 sekundy, aby wyszukiwanie elementu powtarzało się co 500mili sekund
                session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5);

                touchScreen = new RemoteTouchScreen(session);
                Assert.IsNotNull(touchScreen);
            }
        }
Beispiel #3
0
        public static void Setup(TestContext context)
        {
            // Launch Calculator if it is not yet launched
            if (session == null || touchScreen == null)
            {
                session = Utility.CreateNewSession(CommonTestSettings.CalculatorAppId);
                Assert.IsNotNull(session);
                Assert.IsNotNull(session.SessionId);

                try
                {
                    header = session.FindElementByAccessibilityId("Header");
                }
                catch
                {
                    header = session.FindElementByAccessibilityId("ContentPresenter");
                }
                Assert.IsNotNull(header);

                // Initialize touch screen object
                touchScreen = new RemoteTouchScreen(session);
                Assert.IsNotNull(touchScreen);
            }

            // Ensure that calculator is in standard mode
            if (!header.Text.Equals("Standard", StringComparison.OrdinalIgnoreCase))
            {
                session.FindElementByAccessibilityId("NavButton").Click();
                Thread.Sleep(TimeSpan.FromSeconds(1));
                var splitViewPane = session.FindElementByClassName("SplitViewPane");
                splitViewPane.FindElementByName("Standard Calculator").Click();
                Thread.Sleep(TimeSpan.FromSeconds(1));
                Assert.IsTrue(header.Text.Equals("Standard", StringComparison.OrdinalIgnoreCase));
            }
        }
Beispiel #4
0
        public static void Setup(TestContext context)
        {
            // Cleanup leftover objects from previous test if exists
            TearDown();

            // Launch the Edge browser app
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.EdgeAppId);
            session = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);
            Assert.IsNotNull(session);
            Assert.IsNotNull(session.SessionId);

            // Initialize touch screen object
            touchScreen = new RemoteTouchScreen(session);
            Assert.IsNotNull(touchScreen);

            // Track the Microsoft Edge starting page title to be used to initialize all test cases
            System.Threading.Thread.Sleep(3000); // Sleep for 3 seconds
            startingPageTitle = session.Title;

            // Handle Microsoft Edge restored state by starting fresh
            if (startingPageTitle.StartsWith("Start fresh and "))
            {
                try
                {
                    session.FindElementByXPath("//Button[@Name='Start fresh']").Click();
                    System.Threading.Thread.Sleep(3000); // Sleep for 3 seconds
                    startingPageTitle = session.Title;
                }
                catch { }
            }
        }
        public void ScrollToEndOfListUsingRemoteTouchScreenScroll()
        {
            var driver      = StartApp();
            var touchScreen = new RemoteTouchScreen(driver);

            touchScreen.Scroll(0, -300);
            touchScreen.Scroll(0, -300);

            driver.CloseApp();
        }
        public static void TearDown()
        {
            header = null;

            touchScreen = null;
            if (session != null)
            {
                session.Quit();
                session = null;
            }
        }
        void InitTizen(string platform, string profile)
        {
            AppiumOptions option = new AppiumOptions();

            option.AddAdditionalCapability("platformName", platform);
            option.AddAdditionalCapability("deviceName", "emulator-26111");
            option.AddAdditionalCapability("appPackage", "org.tizen.example.WearableUIGallery.Tizen.Wearable");
            option.AddAdditionalCapability("app", "org.tizen.example.WearableUIGallery.Tizen.Wearable-1.0.0.tpk");
            _driver      = new TizenDriver <AppiumWebElement>(new Uri("http://192.168.0.49:4723/wd/hub"), option); //please insert the IP of Appium server.
            _touchScreen = new RemoteTouchScreen(_driver);
            createFolder = false;
        }
Beispiel #8
0
        public static void StopApp()
        {
            TouchScreen = null;

            if (app == null)
            {
                return;
            }

            app.Quit();
            app = null;
        }
Beispiel #9
0
        public static void TearDown()
        {
            // Cleanup RemoteTouchScreen object if initialized
            touchScreen = null;

            // Close the application and delete the session
            if (session != null)
            {
                session.Quit();
                session = null;
            }
        }
Beispiel #10
0
        public static void TearDown()
        {
            // Wyczyszczenie obiektu RemoteTouchScreen jeżeli został zainicjalizowany
            touchScreen = null;

            // Zamknięcie aplikacji i zakończenie sesji
            if (session != null)
            {
                session.Quit();
                session = null;
            }
        }
Beispiel #11
0
        public void DoubleTap()
        {
            // Launch calculator for this specific test case
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.CalculatorAppId);
            calculatorSession = new WindowsDriver <WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);
            Assert.IsNotNull(calculatorSession);
            Assert.IsNotNull(calculatorSession.SessionId);

            // Save application window original size and position
            var originalSize     = calculatorSession.Manage().Window.Size;
            var originalPosition = calculatorSession.Manage().Window.Position;

            // Get maximized window size
            calculatorSession.Manage().Window.Maximize();
            var maximizedSize = calculatorSession.Manage().Window.Size;

            Assert.IsNotNull(maximizedSize);

            // Shrink the window size by 100 pixels each side from maximized size to ensure size changes when maximized
            int offset = 100;

            calculatorSession.Manage().Window.Size = new System.Drawing.Size(maximizedSize.Width - offset, maximizedSize.Height - offset);
            calculatorSession.Manage().Window.Position = new System.Drawing.Point(offset, offset);
            System.Threading.Thread.Sleep(1000); // Sleep for 1 second
            var currentWindowSize = calculatorSession.Manage().Window.Size;

            Assert.IsNotNull(currentWindowSize);
            Assert.AreNotEqual(maximizedSize.Width, currentWindowSize.Width);
            Assert.AreNotEqual(maximizedSize.Height, currentWindowSize.Height);

            // Perform double tap touch on the title bar to maximize calculator window
            calculatorTouchScreen = new RemoteTouchScreen(calculatorSession);
            Assert.IsNotNull(calculatorTouchScreen);
            calculatorTouchScreen.DoubleTap(calculatorSession.FindElementByAccessibilityId("AppNameTitle").Coordinates);
            System.Threading.Thread.Sleep(1000); // Sleep for 1 second
            currentWindowSize = calculatorSession.Manage().Window.Size;
            Assert.IsNotNull(currentWindowSize);
            Assert.AreEqual(maximizedSize.Width, currentWindowSize.Width);
            Assert.AreEqual(maximizedSize.Height, currentWindowSize.Height);

            // Restore application window original size and position
            calculatorSession.Manage().Window.Size = originalSize;
            calculatorSession.Manage().Window.Position = originalPosition;
            System.Threading.Thread.Sleep(1000); // Sleep for 1 second

            // Close the calculator application and delete the session after cleaning up
            calculatorTouchScreen = null;
            calculatorSession.Quit();
            calculatorSession = null;
        }
Beispiel #12
0
        public static void ClassCleanup()
        {
            // Cleanup, close, and delete calculator session in case the cleanup steps were interrupted by exception
            calculatorTouchScreen = null;

            if (calculatorSession != null)
            {
                calculatorSession.Quit();
                calculatorSession = null;
            }

            TearDown();
        }
        public TizenDriverApp()
        {
            AppiumOptions appiumOptions = new AppiumOptions();

            appiumOptions.AddAdditionalCapability("platformName", "Tizen");
            appiumOptions.AddAdditionalCapability("deviceName", "emulator-26101");

            /// need to install this app on target
            appiumOptions.AddAdditionalCapability("appPackage", "org.tizen.PrettyWeather.Tizen");

            _driver = new TizenDriver <TizenElement>(new Uri(address), appiumOptions);

            _touchScreen = new RemoteTouchScreen(_driver);
        }
Beispiel #14
0
        public static void screenVSC7(AndroidDriver driver)
        {
            int i;
            int i2;
            // create collection of Radio Groups
            var vCollection = driver.FindElementsByClassName("android.widget.RadioGroup");
            var vCollRadio  = driver.FindElementsByClassName("android.widget.RadioButton");

            //Loop through Radio Group collection
            for (i = 0; i < (vCollection.Count()); i++)
            {
                vCollRadio = vCollection[i].FindElements(By.ClassName("android.widget.RadioButton"));
                //Check the NO option is selected - If no select it
                for (i2 = 0; i2 < (vCollRadio.Count()); i2++)
                {
                    if (vCollRadio[i2].Text == "No" && vCollRadio[i2].GetAttribute("checked").ToString() == "false")
                    {
                        vCollRadio[i2].Click();
                    }
                }
            }
            //Set up touch screen scrolling
            RemoteTouchScreen touch = new RemoteTouchScreen(driver);

            do
            {
                //scroll to ensure next radio group is present
                touch.Flick(150, -1);
                Thread.Sleep(500);
                // create collection of Radio Groups
                vCollection = driver.FindElementsByClassName("android.widget.RadioGroup");
                //Loop through Radio Group collection
                for (i = 0; i < (vCollection.Count()); i++)
                {
                    vCollRadio = vCollection[i].FindElements(By.ClassName("android.widget.RadioButton"));
                    //Check the NO option is selected - If no select it
                    for (i2 = 0; i2 < (vCollRadio.Count()); i2++)
                    {
                        if (vCollRadio[i2].Text == "No" && vCollRadio[i2].GetAttribute("checked").ToString() == "false")
                        {
                            vCollRadio[i2].Click();
                        }
                    }
                }
            } while (IsElementPresent("Next", driver) == false);

            //select NEXT
            driver.FindElementByName("Next").Click();
        }
Beispiel #15
0
        public static void screenISRD6(AndroidDriver driver)
        {
            //scroll to ensure next button is present
            RemoteTouchScreen touch = new RemoteTouchScreen(driver);

            do
            {
                Thread.Sleep(500);
                touch.Flick(500, -1);
                Thread.Sleep(500);
            } while (IsElementPresent("Next", driver) == false);

            //select NEXT
            driver.FindElementByName("Next").Click();
        }
        public void AddNewItem()
        {
            var driver = StartApp();
            // tap on second item
            var         el1 = driver.FindElementByAccessibilityId("Add");
            TouchAction a   = new TouchAction(driver);

            a.Tap(el1);
            el1.Click();
            var elItemText = driver.FindElementByAccessibilityId("ItemText");

            elItemText.Clear();
            elItemText.SendKeys("This is a new Item");

            var elItemDetail = driver.FindElementByAccessibilityId("ItemDescription");

            elItemDetail.Clear();
            elItemDetail.SendKeys("These are the details");

            var elSave = driver.FindElementByAccessibilityId("Save");

            elSave.Click();

            WaitForProgressbarToDisapear(driver);

            var     touchScreen = new RemoteTouchScreen(driver);
            Boolean found       = false;
            var     maxretries  = 5;
            int     count       = 0;

            while (!found && count++ < maxretries)
            {
                // Good value typically goes around 160 - 200 pixels with diminishing delta on the bigger values
                touchScreen.Flick(0, 180);
                try
                {
                    var el3 = driver.FindElementByName("This is a new Item");
                    found = el3 != null;
                }
                catch (Exception)
                { }
            }
            Assert.IsTrue(found);


            driver.CloseApp();
        }
Beispiel #17
0
        public static void Setup(TestContext context)
        {
            // Cleanup leftover objects from previous test if exists
            TearDown();

            // Launch Alarm Clock
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.AlarmClockAppId);
            session = new WindowsDriver <WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);
            Assert.IsNotNull(session);
            Assert.IsNotNull(session.SessionId);

            // Initialize touch screen object
            touchScreen = new RemoteTouchScreen(session);
            Assert.IsNotNull(touchScreen);
        }
Beispiel #18
0
        public static void Setup(TestContext context)
        {
            // Launch Alarms & Clock application if it is not yet launched
            if (session == null || touchScreen == null || !Utility.CurrentWindowIsAlive(session))
            {
                TearDown();
                session = Utility.CreateNewSession(CommonTestSettings.AlarmClockAppId);
                Assert.IsNotNull(session);
                Assert.IsNotNull(session.SessionId);

                // Set implicit timeout to 2.5 seconds to make element search to retry every 500 ms for at most five times
                session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2.5);

                // Initialize touch screen object
                touchScreen = new RemoteTouchScreen(session);
                Assert.IsNotNull(touchScreen);
            }
        }
Beispiel #19
0
        public static void BaseSetup(TestContext context)
        {
            if (AppSession == null)
            {
                // Launch the test app
                DesiredCapabilities appCapabilities = new DesiredCapabilities();
                appCapabilities.SetCapability("app", "WinAppDriver.Input_xh1ske9axcpv8!App");
                appCapabilities.SetCapability("deviceName", "WindowsPC");
                AppSession = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
                Assert.IsNotNull(AppSession);
                AppSession.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(4);

                AppResult   = AppSession.FindElementByAccessibilityId("ResultText");
                TouchScreen = new RemoteTouchScreen(AppSession);

                // Maximize the test window
                AppSession.Manage().Window.Maximize();
            }

            Assert.IsNotNull(AppResult);
            Assert.IsNotNull(TouchScreen);
        }
        void InitTizen(string platform, string profile)
        {
            AppiumOptions option = new AppiumOptions();

            option.AddAdditionalCapability("platformName", Config.PLATFORM);
            option.AddAdditionalCapability("deviceName", Config.DEVICE_NAME);
            option.AddAdditionalCapability("appPackage", Config.APP_PACKAGE_NAME);
            option.AddAdditionalCapability("app", Config.APP_NAME);
            _driver      = new TizenDriver <AppiumWebElement>(new Uri(Config.APPIUM_SERVER_URI), option);
            _touchScreen = new RemoteTouchScreen(_driver);
            createFolder = false;
#if EMUL_40
            FlickSpeedX = Config.SPEEDX_EMUL_40;
            FlickSpeedY = Config.SPEEDY_EMUL_40;
#elif EMUL_50
            FlickSpeedX = Config.SPEEDX_EMUL_50;
            FlickSpeedY = Config.SPEEDY_EMUL_50;
#else
            FlickSpeedX = Config.SPEEDX_GALAXY_WATCH;
            FlickSpeedY = Config.SPEEDY_GALAXY_WATCH;
#endif
        }
Beispiel #21
0
        public static void Setup(TestContext context)
        {
            // Launch Alarms & Clock application if it is not yet launched
            if (session == null || touchScreen == null)
            {
                TearDown();

                // Create a new session to bring up the Alarms & Clock application
                DesiredCapabilities appCapabilities = new DesiredCapabilities();
                appCapabilities.SetCapability("app", AlarmClockAppId);
                session = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
                Assert.IsNotNull(session);
                Assert.IsNotNull(session.SessionId);

                // Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times
                session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5);

                // Initialize touch screen object
                touchScreen = new RemoteTouchScreen(session);
                Assert.IsNotNull(touchScreen);
            }
        }
Beispiel #22
0
        public static void TearDown()
        {
            // Cleanup RemoteTouchScreen object if initialized
            touchScreen = null;

            // Close the application and delete the session
            if (session != null)
            {
                try
                {
                    session.Close();
                    var currentHandle = session.CurrentWindowHandle; // This should throw if the window is closed successfully

                    // When the Edge window remains open because of multiple tabs are open, attempt to close modal dialog
                    var closeAllButton = session.FindElementByXPath("//Button[@Name='Close all']");
                    closeAllButton.Click();
                }
                catch { }

                session.Quit();
                session = null;
            }
        }
Beispiel #23
0
        public static void StartApp()
        {
            if (app != null && TouchScreen != null)
            {
                return;
            }

            StopApp();

            var opts = new AppiumOptions();

            opts.AddAdditionalCapability("app", AppId);

            app = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), opts);
            Assert.IsNotNull(app);
            Assert.IsNotNull(app.SessionId);

            // Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times
            app.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5);

            TouchScreen = new RemoteTouchScreen(app);
            Assert.IsNotNull(TouchScreen);
        }
Beispiel #24
0
        public static void BaseTearDown()
        {
            // Cleanup the AppResult WindowsElement object if initialized
            AppResult = null;

            // Cleanup RemoteTouchScreen object if initialized
            TouchScreen = null;

            // Close the application and delete the session
            if (AppSession != null)
            {
                try
                {
                    AppSession.Close();

                    // This should throw if the window is closed successfully
                    var currentHandle = AppSession.CurrentWindowHandle;
                }
                catch { }

                AppSession.Quit();
                AppSession = null;
            }
        }
        void InitTizen(string platform, string profile)
        {
            AppiumOptions option = new AppiumOptions();

            option.AddAdditionalCapability("platformName", platform);
            option.AddAdditionalCapability("deviceName", DriverConfig.DEVICE_NAME);
            option.AddAdditionalCapability("appPackage", DriverConfig.APP_PACKAGE_NAME);
            option.AddAdditionalCapability("app", DriverConfig.APP_NAME);
            // ATTENTION: this is a custom option and is not standard in the appium-tizen-driver
            option.AddAdditionalCapability("appLocation", DriverConfig.GetAppLocation());
            _driver      = new TizenDriver <AppiumWebElement>(new Uri(DriverConfig.APPIUM_SERVER_URI), option);
            _touchScreen = new RemoteTouchScreen(_driver);
            createFolder = false;
#if EMUL_40
            FlickSpeedX = DriverConfig.SPEEDX_EMUL_40;
            FlickSpeedY = DriverConfig.SPEEDY_EMUL_40;
#elif EMUL_50
            FlickSpeedX = DriverConfig.SPEEDX_EMUL_50;
            FlickSpeedY = DriverConfig.SPEEDY_EMUL_50;
#else
            FlickSpeedX = DriverConfig.SPEEDX_GALAXY_WATCH;
            FlickSpeedY = DriverConfig.SPEEDY_GALAXY_WATCH;
#endif
        }
Beispiel #26
0
 public TouchCapableRemoteWebDriver(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
     : base(commandExecutor, desiredCapabilities)
 {
     TouchScreen = new RemoteTouchScreen(this);
 }
Beispiel #27
0
 public TouchCapableRemoteWebDriver(Uri remoteAddress, ICapabilities desiredCapabilities, TimeSpan commandTimeout)
     : base(remoteAddress, desiredCapabilities, commandTimeout)
 {
     TouchScreen = new RemoteTouchScreen(this);
 }
Beispiel #28
0
 public TouchCapableRemoteWebDriver(Uri remoteAddress, ICapabilities desiredCapabilities)
     : base(remoteAddress, desiredCapabilities)
 {
     TouchScreen = new RemoteTouchScreen(this);
 }
Beispiel #29
0
 public TouchCapableRemoteWebDriver(ICapabilities desiredCapabilities)
     : base(desiredCapabilities)
 {
     TouchScreen = new RemoteTouchScreen(this);
 }
Beispiel #30
0
 public DroidDriver(Uri remoteAddress, ICapabilities desiredCapabilities, TimeSpan commandTimeout) : base(remoteAddress, desiredCapabilities, commandTimeout)
 {
     _remoteAddr = remoteAddress.ToString();
     TouchScreen = new RemoteTouchScreen(this);
 }