Ejemplo n.º 1
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 { }
            }
        }
Ejemplo n.º 2
0
 public String GetCategoryTitle()
 {
     /*
      * Steps:
      * 1. If '< UIKitCatalog' element appear then click on it
      * 2. Click on "Car and Truck" Categories on Homepage
      * 3. Click on "Acura" Categories
      * 4. Return the category text title which should be "Acura"
      *
      * Expected:
      * General Information is "Acura".
      */
     if (driver_.FindElementByXPath(goBackButton).Displayed)
     {
         driver_.FindElementByXPath(goBackButton).Click();
         Helpers.Pause(2);
     }
     driver_.FindElementByXPath(categoryXpath).Click();
     Helpers.Pause(2);
     return(driver_.FindElementByXPath(categoryTitle).Text);
 }
        public static void Main(string[] args)
        {
            DesiredCapabilities caps = new DesiredCapabilities();

            caps.SetCapability("browserstack.user", userName);
            caps.SetCapability("browserstack.key", accessKey);

            caps.SetCapability("realMobile", true);
            caps.SetCapability("device", "iPhone 7");
            caps.SetCapability("app", "bs://<hashed app-id>");
            IOSDriver <IOSElement> driver = new IOSDriver <IOSElement> (new Uri("http://hub.browserstack.com/wd/hub"), caps);

            IOSElement loginButton = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
                ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Log In"))
                );

            loginButton.Click();
            IOSElement emailTextField = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
                ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Email address"))
                );

            // element.SendKeys() method is not supported in Appium 1.6.3
            // Workaround for SendKeys() method:
            emailTextField.Click();
            String email = "*****@*****.**";

            for (int i = 0; i < email.Length; i++)
            {
                driver.FindElementByXPath("//XCUIElementTypeKey[@name='" + email[i] + "']").Click();
            }

            driver.FindElementByAccessibilityId("Next").Click();
            System.Threading.Thread.Sleep(5000);


            IReadOnlyList <IOSElement> textElements = driver.FindElementsByXPath("//XCUIElementTypeStaticText");

            String matchedString = "";

            foreach (IOSElement textElement in textElements)
            {
                String textContent = textElement.Text;
                if (textContent.Contains("not registered"))
                {
                    matchedString = textContent;
                }
            }

            Console.WriteLine(matchedString);
            driver.Quit();
        }
Ejemplo n.º 4
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;
            }
        }
Ejemplo n.º 5
0
        public static void TearDown()
        {
            ReturnToMainPage();
            SwitchToAlarmTab();

            // Delete all created alarms
            while (true)
            {
                try
                {
                    var alarmEntry = AlarmClockSession.FindElementByXPath(string.Format("//ListItem[starts-with(@Name, \"{0}\")]", NewAlarmName));
                    AlarmClockSession.Mouse.ContextClick(alarmEntry.Coordinates);
                    AlarmClockSession.FindElementByName("Delete").Click();
                }
                catch
                {
                    break;
                }
            }

            AlarmClockSession.Quit();
            AlarmClockSession = null;
        }
Ejemplo n.º 6
0
 // 2. We override all available methods and use XPath expression for finding an element with name starting with.
 public override IOSElement FindElement(IOSDriver <IOSElement> searchContext)
 {
     return(searchContext.FindElementByXPath(_locatorValue));
 }
Ejemplo n.º 7
0
        public void FindElementByXPath()
        {
            IOSElement element = session.FindElementByXPath("//*[@Name=\"Alarm Collection\"]");

            Assert.IsNotNull(element);
        }
Ejemplo n.º 8
0
        public void ErrorFindElementByUnsupportedLocatorXPath()
        {
            IOSElement element = session.FindElementByXPath("Query");

            Assert.Fail("Exception should have been thrown");
        }
Ejemplo n.º 9
0
        public void testNavigationOnAcuraSupportCommunity()
        {
            Console.WriteLine("should allow to navigate to some devices on Acura Support Community");

            /*
             * Steps:
             * 1. Click on "Car and Truck" Categories on Homepage
             * 2. Click on "Acura" Categories
             *
             * Expected:
             * 1. General Information is "Acura".
             * 2.Verify five devices below displays.
             * + Acura Integra
             * + Acura MDX
             * + Acura RL
             * + Acura TL
             * + Acura TSX
             */

            driver.FindElementByXPath("//XCUIElementTypeButton[@name='START A REPAIR']").Click();
            Thread.Sleep(5000);
            driver.FindElementByXPath("//*[@name='Car and Truck']").Click();
            Thread.Sleep(2000);
            driver.FindElementByXPath("//*[@name='Acura']").Click();
            Thread.Sleep(2000);
            WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 0, 60));

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//XCUIElementTypeNavigationBar")));

            string acuraText = driver
                               .FindElementByXPath("//XCUIElementTypeNavigationBar").GetAttribute("name");
            bool hasAcuraIntegra = driver
                                   .FindElementByXPath("//XCUIElementTypeStaticText[@name='Acura Integra']").Displayed;
            bool hasAcuraMDX = driver
                               .FindElementByXPath("//XCUIElementTypeStaticText[@name='Acura MDX']").Displayed;
            bool hasAcuraRL = driver
                              .FindElementByXPath("//XCUIElementTypeStaticText[@name='Acura RL']").Displayed;
            bool hasAcuraTL = driver
                              .FindElementByXPath("//XCUIElementTypeStaticText[@name='Acura TL']").Displayed;
            bool hasAcuraTSX = driver
                               .FindElementByXPath("//XCUIElementTypeStaticText[@name='Acura TSX']").Displayed;

            driver.CloseApp();

            Assert.AreEqual(acuraText, "Acura");
            Assert.AreEqual(hasAcuraIntegra, true);
            Assert.AreEqual(hasAcuraMDX, true);
            Assert.AreEqual(hasAcuraRL, true);
            Assert.AreEqual(hasAcuraTL, true);
            Assert.AreEqual(hasAcuraTSX, true);
        }
Ejemplo n.º 10
0
        public void AppiumTestMethod()
        {
            //Write your test here
            try
            {
                // write your code here
                // press Don't Allow button on Notifications screen if it appears
                try
                {
                    //IWebElement alert = driver.FindElementByXPath("//UIAAlert[contains(@name, \"Send You Notifications\")]");
                    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(2));
                    driver.FindElementByName("Don't Allow").Click();
                }
                catch (NoSuchElementException n1)
                {
                    Trace.WriteLine("No notifications popup, just plow ahead!");
                }

                // press OK button on Welcome popup if it appears
                try
                {
                    IWebElement header = driver.FindElementByName("Welcome");
                    IWebElement okBtn  = driver.FindElementByName("OK");
                    okBtn.Click();
                }
                catch (NoSuchElementException n1)
                {
                    Trace.WriteLine("No welcome popup, just plow ahead!");
                }

                // Press "New Note" button (on right end of header)
                driver.FindElementByName("add os7").Click();

                // Verify that arrive at the New Task screen
                try
                {
                    IWebElement nTask = driver.FindElementByName("New Task");
                }
                catch (NoSuchElementException n)
                {
                    Trace.WriteLine("Did not reach New Task window!");
                    throw n;
                }

                // Enter a title for the new task
                IWebElement title = driver.FindElementByIosUIAutomation("UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0]");
                title.SendKeys("Prepare the script for Native Application");

                // Enter text into the Details field
                IWebElement detail = driver.FindElementByIosUIAutomation(".textFields()[1]");
                detail.SendKeys("Select an application, upload, and use Object Spy");

                // Click "Done" to go to next stage
                driver.FindElementByName("Done").Click();

                // Click on the Due Date field to select the due date
                try
                {
                    driver.FindElementByXPath("//UIAStaticText[@name='Due Date']").Click();
                }
                catch (NoSuchElementException n)
                {
                    Trace.WriteLine("Not showing second stage display!");
                    throw n;
                }
                // select that task is due next week
                driver.FindElementByName("+1 Week").Click();

                // Click "Done" to complete the task definition
                driver.FindElementByName("Done").Click();

                // Verify that task is listed
                try
                {
                    IWebElement nTask = driver.FindElementByName("Prepare the script for Native Application");
                }
                catch (NoSuchElementException n)
                {
                    Trace.WriteLine("The task is not listed!");
                    throw n;
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine("Failed due to an exception:" + e.Message);
            }
        }