Beispiel #1
0
        public void Login(string uservalue, string passvalue, string userid, string passid)
        {
            var duration = new Stopwatch();
            var wait     = new WebDriverWait(_driver, TimeSpan.FromSeconds(TestConstants.Wait));

            try
            {
                duration.Start();
                wait.Until(
                    x =>
                    x.FindElement(
                        By.XPath(passid)));

                var element = _driver.FindElement(By.XPath(userid));
                element.Click();
                Thread.Sleep(TestConstants.Delay);
                element.SendKeys(uservalue);
                Thread.Sleep(TestConstants.Delay);
                var element2 = _driver.FindElement(By.XPath(passid));
                Thread.Sleep(TestConstants.Delay);
                element2.SendKeys(passvalue);
                Thread.Sleep(TestConstants.Delay);
                element.SendKeys(Keys.Return);
                duration.Stop();
                Log.Info(MethodBase.GetCurrentMethod().Name + TestConstants.Sp + duration.ElapsedMilliseconds + TestConstants.Ms);
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw new ElementNotVisibleException();
            }
        }
        public void FindElementTestCase()
        {
            By byAccessibilityId = new ByAccessibilityId("Graphics");

            Assert.AreNotEqual(driver.FindElement(byAccessibilityId).Text, null);
            Assert.GreaterOrEqual(driver.FindElements(byAccessibilityId).Count, 1);

            driver.FindElementByAccessibilityId("Graphics").Click();
            Assert.IsNotNull(driver.FindElementByAccessibilityId("Arcs"));
            driver.Navigate().Back();

            Assert.IsNotNull(driver.FindElementByName("App"));

            Assert.IsNotNull(driver.FindElement(new ByAndroidUIAutomator("new UiSelector().clickable(true)")).Text);
            var els = driver.FindElementsByAndroidUIAutomator("new UiSelector().clickable(true)");

            Assert.GreaterOrEqual(els.Count, 12);

            var els2 = driver.FindElements(new ByAndroidUIAutomator("new UiSelector().enabled(true)"));

            Assert.GreaterOrEqual(els2.Count, 20);

            els = driver.FindElementsByAndroidUIAutomator("new UiSelector().enabled(true)");
            Assert.GreaterOrEqual(els.Count, 20);
            Assert.IsNotNull(driver.FindElementByXPath("//android.widget.TextView[@text='API Demos']"));
        }
        public void PerformActionsButtons()
        {
            By  byScrollLocator = new ByAndroidUIAutomator("new UiSelector().text(\"Views\");");
            var viewsButton     = _driver.FindElement(byScrollLocator);

            viewsButton.Click();

            var controlsViewButton = _driver.FindElementByXPath("//*[@text='Controls']");

            controlsViewButton.Click();

            var lightThemeButton = _driver.FindElementByXPath("//*[@text='1. Light Theme']");

            lightThemeButton.Click();
            _driver.HideKeyboard();

            // rotate the device
            ////var rotatable = (IRotatable)_driver;
            ////rotatable.Orientation = ScreenOrientation.Landscape;
            ////_driver.ToggleWifi();

            var saveButton = _driver.FindElementByXPath("//*[@text='Save']");

            Assert.IsTrue(saveButton.Enabled);
        }
Beispiel #4
0
        public void FindByAccessibilityIdTest()
        {
            By byAccessibilityId = new ByAccessibilityId("Graphics");

            Assert.AreNotEqual(_driver.FindElement(byAccessibilityId).Text, null);
            Assert.GreaterOrEqual(_driver.FindElements(byAccessibilityId).Count, 1);
        }
Beispiel #5
0
        public void ScrollingToSubElement()
        {
            _driver.FindElementByAccessibilityId("Views").Click();
            var list    = _driver.FindElement(By.Id("android:id/list"));
            var locator = new ByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView("
                                                   + "new UiSelector().text(\"Radio Group\"));");
            var radioGroup = list.FindElement(locator);

            Assert.NotNull(radioGroup.Location);
        }
Beispiel #6
0
        public void RunAction()
        {
            // Create Action
            var action = new ClearFieldsAction();

            // Prepare state
            driver.FindElement(By.Id("name")).SendKeys("John Smith");
            driver.FindElement(By.Id("password")).SendKeys("12345");

            // Run action
            runner.Run(action);
        }
Beispiel #7
0
 public void TestAndroidApp()
 {
     driver.FindElement(By.XPath("xpath=//*[@id='usernameTextField']")).SendKeys("company");
     driver.FindElement(By.XPath("xpath=//*[@id='passwordTextField']")).SendKeys("company");
     driver.FindElement(By.XPath("xpath=//*[@id='loginButton']")).Click();
     driver.FindElement(By.XPath("xpath=//*[@id='makePaymentButton']")).Click();
     driver.FindElement(By.XPath("xpath=//*[@id='phoneTextField']")).SendKeys("123456");
     driver.FindElement(By.XPath("xpath=//*[@id='nameTextField']")).SendKeys("Test");
     driver.FindElement(By.XPath("xpath=//*[@id='amountTextField']")).SendKeys("10");
     driver.FindElement(By.XPath("xpath=//*[@id='countryTextField']")).SendKeys("US");
     driver.FindElement(By.XPath("xpath=//*[@id='sendPaymentButton']")).Click();
     driver.FindElement(By.XPath("xpath=//*[@id='button1']")).Click();
 }
Beispiel #8
0
        public void TestCreateSimpleTask()
        {
            driver.FindElement(By.Id("btn_welcome_log_in")).Click();
            // *** Google Play Services Activity ***
            driver.FindElement(By.Id("button1")).Click();

            // *** Login Activity ****
            driver.FindElement(By.Id("log_in_email")).SendKeys(EMAIL);
            driver.FindElementById("log_in_password").SendKeys(PASSWORD);
            driver.FindElementById("btn_log_in").Click();

            // *** Google Play Services Activity ***
            driver.FindElementById("button1").Click();

            // *** Goolge Play services in not supported ***
            //driver.FindElementById("button1").Click();

            // Clicking on the Today menu item
            driver.FindElement(By.XPath("//android.widget.TextView[@text='Today']")).Click();

            // Creating a new task
            driver.FindElementById("fab").Click();
            String           taskName = "Automated task" + DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
            AppiumWebElement message  = driver.FindElementById("message");

            message.SendKeys(taskName + " #work");
            driver.FindElementById("button1").Click();

            // Going back
            driver.FindElementById("action_mode_close_button").Click();



            // Searching for the newly created item
            ReadOnlyCollection <AppiumWebElement> items = driver.FindElements(By.XPath("//android.widget.RelativeLayout[@resource-id='com.todoist:id/item']/android.widget.TextView"));
            Boolean found = false;

            foreach (AppiumWebElement item in items)
            {
                Console.Write("Item: " + item.Text);
                if (item.Text.Equals(taskName))
                {
                    found = true;
                    break;
                }
            }
            Assert.IsTrue(found, "Item was not created");


            Thread.Sleep(1000);
        }
        public void AddOneSet()
        {
            AndroidDriver <AppiumWebElement> driver = StartApp();

            var el1 = driver.FindElement(MobileBy.Id("button_toggle_volume"));

            el1.Click();

            var setNumber         = driver.FindElement(MobileBy.Id("edit_number_sets"));
            var numberOfSets      = setNumber.Text;
            var expectedSetNumber = "3";

            Assert.IsTrue(numberOfSets == expectedSetNumber);
        }
Beispiel #10
0
        public void TestChromeNavigation()
        {
            var page = "Tesouro Direto";

            driver.FindElement(By.XPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v4.view.ViewPager/android.widget.FrameLayout/android.widget.Button")).Click();
            driver.FindElement(By.XPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v4.view.ViewPager/android.widget.FrameLayout/android.widget.Button")).Click();
            driver.FindElement(By.XPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v4.view.ViewPager/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.Button[1]")).Click();
            driver.FindElement(By.XPath("//android.support.v7.widget.RecyclerView[@content-desc=\"New tab\"]/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.EditText")).SendKeys("www.tesourodireto.com.br");
            System.Threading.Thread.Sleep(123123);
            driver.FindElement(By.XPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.EditText")).SendKeys("www.google.com");


            //Assert.AreEqual(page, driver.FindElement(By.XPath, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.EditText"))
        }
Beispiel #11
0
 public void TestAndroidApp()
 {
     driver.Navigate().GoToUrl("https://amazon.com");
     if (driver.Capabilities.GetCapability("device.category").Equals("TABLET"))
     {
         driver.FindElement(By.XPath("//*[@name='field-keywords']")).SendKeys("iPhone");
         driver.FindElement(By.XPath("//*[@text='Go']")).Click();
     }
     else
     {
         driver.FindElement(By.XPath("//*[@name='k']")).SendKeys("iPhone");
         driver.FindElement(By.XPath("//*[@value='Go']")).Click();
     }
 }
        public void AddNewItem()
        {
            AndroidDriver <AppiumWebElement> driver = StartApp();

            // tap on second item
            var el1 = driver.FindElement(MobileBy.AccessibilityId("Add"));

            el1.Click();

            var elItemText = driver.FindElement(MobileBy.AccessibilityId("ItemText"));

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

            var elItemDetail = driver.FindElement(MobileBy.AccessibilityId("ItemDescription"));

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

            var elSave = driver.FindElement(MobileBy.AccessibilityId("Save"));

            elSave.Click();
            CreateScreenshot(driver);

            WaitForProgressbarToDisapear(driver);

            CreateScreenshot(driver);

            var scrollableElement = driver.FindElement(MobileBy.AccessibilityId("ItemsListView"));

            Func <AppiumWebElement> FindElementAction = () =>
            {
                // find all text views
                // check if the text matches
                var elements = driver.FindElementsByClassName("android.widget.TextView");
                foreach (var textView in elements)
                {
                    if (textView.Text == "This is a new Item")
                    {
                        return(textView);
                    }
                }
                return(null);
            };

            var elementFound = ScrollUntillItemFound(driver, scrollableElement, FindElementAction, 4);

            Assert.IsTrue(elementFound != null);
            driver.CloseApp();
        }
        public Tuple <bool, IWebElement> AwaitText(AndroidDriver <IWebElement> driver, string text, int sek = 20)
        {
            var           by   = By.XPath("//[contains(@text, '" + text + "')][last()]");
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(sek));

            try
            {
                wait.Until(ExpectedConditions.ElementIsVisible(by));
                return(new Tuple <bool, IWebElement>(true, driver.FindElement(by)));
            }
            catch
            {
                return(new Tuple <bool, IWebElement>(false, driver.FindElement(By.XPath("//"))));
            }
        }
Beispiel #14
0
        public void MasterDetail()
        {
            System.Environment.SetEnvironmentVariable("ANDROID_HOME", @"C:\Program Files (x86)\Android\android-sdk");
            System.Environment.SetEnvironmentVariable("JAVA_HOME", @"C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin");

            var capabilities = new AppiumOptions();

            // automatic start of the emulator if not running
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.Avd, "demo_device");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AvdArgs, "-no-boot-anim -no-snapshot-load");
            capabilities.AddAdditionalCapability(MobileCapabilityType.FullReset, true);
            // connecting to a device or emulator
            capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "2471736c36037ece");
            capabilities.AddAdditionalCapability(MobileCapabilityType.AutomationName, "UiAutomator2");
            // specifyig which app we want to install and launch
            var currentPath = Directory.GetCurrentDirectory();

            Console.WriteLine($"Current path: {currentPath}");
            var packagePath = Path.Combine(currentPath, @"..\..\..\AppsToTest\com.fluentbytes.carvedrock-x86.apk");

            packagePath = Path.GetFullPath(packagePath);
            Console.WriteLine($"Package path: {packagePath}");
            capabilities.AddAdditionalCapability(MobileCapabilityType.App, packagePath);

            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "com.fluentbytes.carvedrock");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, "crc641782d5af3c9cf50a.MainActivity");

            var _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();

            _appiumLocalService.Start();;
            var driver = new AndroidDriver <AppiumWebElement>(_appiumLocalService, capabilities);
            // tap on second item
            var el1 = driver.FindElement(MobileBy.AccessibilityId("Second item"));

            el1.Click();

            var el2 = driver.FindElement(MobileBy.AccessibilityId("ItemText"));

            Assert.IsTrue(el2.Text == "Second item");

            driver.PressKeyCode(AndroidKeyCode.Back);

            var el3 = driver.FindElement(MobileBy.AccessibilityId("Fourth item"));

            Assert.IsTrue(el3 != null);

            driver.CloseApp();
        }
        public Tuple <bool, IWebElement> AwaitElementClass(AndroidDriver <IWebElement> driver, int sek = 20, string type = "EditText", string nameSpace = "android.widget")
        {
            var           by   = By.ClassName(nameSpace + "." + type);
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(sek));

            try
            {
                wait.Until(ExpectedConditions.ElementExists(by));
                //wait.Until(ExpectedConditions.ElementIsVisible(by));
                return(new Tuple <bool, IWebElement>(true, driver.FindElement(by)));
            }
            catch
            {
                return(new Tuple <bool, IWebElement>(false, driver.FindElement(By.XPath("//"))));
            }
        }
        public void CreateAndroidDriverInGridWithWebAppByDefaultPasses()
        {
            System.Console.WriteLine($"Thread # [{System.Threading.Thread.CurrentThread.ManagedThreadId}]");
            //Check if this is true for IOSdriver
            AndroidDriver <AppiumWebElement> driver = MobileDriver.Get <AndroidDriver <AppiumWebElement> >();
            // TestLogs.WriteDeviceLogs();
            ServerCommandExecutor executor = new ServerCommandExecutor(this.GetParameters().ServerUri, driver.SessionId);

            Console.WriteLine($"Current device orientation is:{driver.Orientation}");
            executor.Execute("setOrientation", new Dictionary <string, object> {
                { "orientation", "LANDSCAPE" }
            });
            Console.WriteLine($"New device orientation is: {driver.Orientation}");
            TestContext.WriteLine($"Web app SessionId is:[{driver.SessionId}]");
            Assert.NotNull(driver, $"driver cannot be null");
            /*System.Console.WriteLine($"Server running test [{driver.PlatformName}]");*/
            driver.Navigate().GoToUrl("http://google.com");
            System.Console.WriteLine($"Curretn activity:{driver.CurrentActivity}");

            Wait.ForPageToLoad();
            AppiumWebElement searchTextControl = driver.FindElement(By.CssSelector("div.SDkEP input.gLFyf"), 10);

            searchTextControl.Click();
            searchTextControl.SendKeys("Hello there@@");
            Wait.Seconds(3);
            Assert.AreEqual(driver.Contexts.Count, 2, "Multiple Contexts");
            Assert.AreEqual(driver.Context.ToString(), "CHROMIUM", "Expected Chromium context");
            OpenQA.Selenium.Remote.Response result1 = executor.Execute("getAvailableLogTypes");
            Console.WriteLine($"Supported Log Types:\n {result1.ToJson()}");
        }
Beispiel #17
0
        public static string ReadMessege(ReportsManager reports, string testname)
        {
            // Set the capabilities instance
            DesiredCapabilities capabilities = new DesiredCapabilities();

            capabilities.SetCapability("deviceName", "3a2bad9");

            // Set device capabilities
            capabilities.SetCapability("PlatformName", "Android");
            // Set application capabilities
            //SMS
            capabilities.SetCapability("appPackage", dictProfiles["MessegingAppPckg"]);
            capabilities.SetCapability("appActivity", dictProfiles["MessegingAppActivty"]);

            // Create new Appium driver pointing to the MC server and based on the capabilities set above.
            AndroidDriver <AppiumWebElement> Phone = new AndroidDriver <AppiumWebElement>(new Uri(MC_SERVER + "/wd/hub"), capabilities, TimeSpan.FromMinutes(10));

            // Create a wait object instance
            WebDriverWait waitController = new WebDriverWait(Phone, TimeSpan.FromSeconds(30));
            MobileCore    mobile         = new MobileCore();

            try
            {
                mobile.MobileFindElement(waitController, "TextView", "text", "Write new message");
                mobile.MobileClicks(waitController, "ImageButton", "content-desc", "Navigate up");
            }
            catch { }

            mobile.MobileFindElement(waitController, "TextView", "text", "Messaging");

            var i = Phone.FindElement(By.XPath("//android.widget.TextView[@resource-id='" + Sony.sms_resID + "']")).Text.Substring(47);

            //com.android.mms:id / subject

            Phone.FindElement(By.XPath("//android.widget.TextView[@resource-id='" + Sony.sms_resID + "']")).Click();
            Thread.Sleep(3000);

            //getBrowser the sms sent
            reports.Screenshot(Phone, "Sms sent to phone", testname);
            Console.WriteLine(i);
            Console.WriteLine(dictProfiles["MessegingAppPckg"]);
            Console.WriteLine(dictProfiles["MessegingAppActivty"]);

            return(i);
        }
Beispiel #18
0
 public AppiumWebElement WaitForElementDisplayed(By element, int time = 30)
 {
     while (time-- > 0)
     {
         try
         {
             var _element = _driver.FindElement(element);
             if (_element.Displayed)
             {
                 return(_element);
             }
         }
         catch
         {
             System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
         }
     }
     throw new ElementNotVisibleException($"Element {element} is not visible after {time} seconds");
 }
Beispiel #19
0
        public void Appium_Android_CheckRegionWithIgnoreRegion()
        {
            var labelInContainer = driver_.FindElement(labelInContainerSelector_);

            eyes_.Check("Image Container", Target.Region(containerSelector_).Ignore(labelInContainer).Ignore(imageInContainerSelector_));
            expectedIgnoreRegions_ = new HashSet <Region>()
            {
                new Region(53, 0, 254, 22), new Region(0, 21, 360, 234)
            };
        }
Beispiel #20
0
        public void First_Test()
        {
            var inputField =
                driver.FindElement(By.Id("com.android.example.github:id/input"));

            inputField.SendKeys("Selenium");
            inputField.Click();
            driver.PressKeyCode(AndroidKeyCode.Enter);
            var seleniumField =
                driver.FindElement(By.XPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.FrameLayout[1]/android.view.ViewGroup/android.widget.TextView[2]"));

            seleniumField.Click();
            var barancev = driver.FindElement(By.XPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.FrameLayout[2]/android.view.ViewGroup"));

            barancev.Click();
            var nameBarancev = driver.FindElement(By.XPath("//android.widget.TextView[@content-desc='user name']"));

            Assert.AreEqual("Alexei Barantsev", nameBarancev.Text);
        }
        public void OpenKMSApp()
        {
            DesiredCapabilities caps = new DesiredCapabilities();

            caps.SetCapability("deviceName", "Note5");
            caps.SetCapability("udid", "0415313132353234");
            caps.SetCapability("appActivity", ".activities.login.LoginActivity");
            //caps.SetCapability("appWaitActivity", ".activities.main.MainActivity");
            caps.SetCapability("appWaitPackage", "com.kms_technology.kmsdirectory");
            var driver = new AndroidDriver <AppiumWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), caps);

            driver.FindElement(By.Id("com.kms_technology.kmsdirectory:id/userNameEditText")).SendKeys("minhhoang");
            driver.FindElement(By.Id("com.kms_technology.kmsdirectory:id/passwordEditText")).SendKeys("Kms@1234");
            driver.FindElement(By.Id("com.kms_technology.kmsdirectory:id/loginBtn")).Click();
            System.Threading.Thread.Sleep(10000);
            driver.FindElement(By.Id("com.kms_technology.kmsdirectory:id/editText")).SendKeys("minh hoang");
            Console.WriteLine(driver.FindElement(By.Id("com.kms_technology.kmsdirectory:id/editText")).Text);
            System.Threading.Thread.Sleep(10000);
            driver.Quit();
        }
        public void CheckMasterDetailAndBack()
        {
            AndroidDriver <AppiumWebElement> driver = StartApp();

            // tap on second item
            var el1 = driver.FindElement(MobileBy.AccessibilityId("Second item"));

            el1.Click();

            var el2 = driver.FindElement(MobileBy.AccessibilityId("ItemText"));

            Assert.IsTrue(el2.Text == "Second item");

            driver.PressKeyCode(AndroidKeyCode.Back);

            var el3 = driver.FindElement(MobileBy.AccessibilityId("Fourth item"));

            Assert.IsTrue(el3 != null);

            driver.CloseApp();
        }
Beispiel #23
0
 private bool IsSkipDFPresent(By by)
 {
     try
     {
         driver.FindElement(by);
         return(true);
     }
     catch (NoSuchElementException)
     {
         return(false);
     }
 }
Beispiel #24
0
        public void LoginPage()
        {
            TestScreenShot();
            //Click on Accept button
            driver.FindElement(By.Id("com.pcloudy.appiumdemo:id/accept")).Click();
            TestScreenShot();

            //Click on flight button
            driver.FindElement(By.XPath("//android.widget.Button[@resource-id='com.pcloudy.appiumdemo:id/flightButton']")).Click();
            TestScreenShot();

            //Select from location
            driver.FindElement(By.XPath("//android.widget.Spinner[@resource-id='com.pcloudy.appiumdemo:id/spinnerfrom']")).Click();
            TestScreenShot();

            driver.FindElement(By.XPath("//android.widget.CheckedTextView[@resource-id='android:id/text1' and @text='Bangalore, India (BLR)']")).Click();
            TestScreenShot();

            //Select to location
            driver.FindElement(By.XPath("//android.widget.Spinner[@resource-id='com.pcloudy.appiumdemo:id/spinnerto']")).Click();
            TestScreenShot();

            driver.FindElement(By.XPath("//android.widget.CheckedTextView[@resource-id='android:id/text1' and @text='Pune, India (PNQ)']")).Click();
            TestScreenShot();

            //Select one way trip
            driver.FindElement(By.XPath("//android.widget.RadioButton[@resource-id='com.pcloudy.appiumdemo:id/singleTrip']")).Click();
            TestScreenShot();

            //Select departure time
            driver.FindElement(By.XPath("//android.widget.TextView[@resource-id='com.pcloudy.appiumdemo:id/txtdepart']")).Click();
            TestScreenShot();

            driver.FindElement(By.XPath("//android.widget.Button[@resource-id='android:id/button1' and @text='OK']")).Click();
            TestScreenShot();

            //Click on search flights button
            driver.FindElement(By.XPath("//android.widget.Button[@resource-id='com.pcloudy.appiumdemo:id/searchFlights']")).Click();
            TestScreenShot();
        }
Beispiel #25
0
        // Android Finder
        public AndroidElement  TDFinder(string propType, string propValue, AndroidDriver <AndroidElement> _driverANDROID)
        {
            AndroidElement eToUse = null;

            switch (propType)
            {
            case "Id":
                eToUse = _driverANDROID.FindElement(By.Id(propValue));
                break;

            case "Name":
                eToUse = _driverANDROID.FindElement(By.Name(propValue));
                break;

            case "Class":
                eToUse = _driverANDROID.FindElement(By.ClassName(propValue));
                break;

            case "CssSelector":
                eToUse = _driverANDROID.FindElement(By.CssSelector(propValue));
                break;

            case "LinkText":
                eToUse = _driverANDROID.FindElement(By.LinkText(propValue));
                break;

            case "XPath":
                eToUse = _driverANDROID.FindElement(By.XPath(propValue));
                break;
            }
            return(eToUse);
        }
        public void USSD_Test()
        {
            try
            {
                String testname = MethodBase.GetCurrentMethod().Name;
                reports = new ReportsManager(Core.getBrowser, Core.getURL, className, testname);
                //   reports.verifyURL(Core.getURL);

                // Set the capabilities instance
                DesiredCapabilities capabilities = new DesiredCapabilities();
                capabilities.SetCapability("deviceName", Device.Emulator);

                // Set device capabilities
                capabilities.SetCapability("PlatformName", "Android");

                //voda app
                capabilities.SetCapability("appPackage","com.android.dialer");
                capabilities.SetCapability("appActivity","com.android.dialer.DialtactsActivity");

                // Create new Appium driver pointing to the MC server and based on the capabilities set above.
                AndroidDriver<AppiumWebElement> Phone = new AndroidDriver<AppiumWebElement>(new Uri(MC_SERVER + "/wd/hub"), capabilities, TimeSpan.FromMinutes(10));

                // Create a wait object instance
                WebDriverWait waitController = new WebDriverWait(Phone, TimeSpan.FromSeconds(30));

                Thread.Sleep(3000);

                //Dialing *111# on a mobile device
                reports.Screenshot(Phone,"Dialer Opened", testname);
                Phone.FindElement(By.Id("star")).Click();
                Phone.FindElement(By.Id("one")).Click();
                Phone.FindElement(By.Id("one")).Click();
                Phone.FindElement(By.Id("one")).Click();
                Phone.FindElement(By.Id("pound")).Click();

                //Press Call button
                reports.Screenshot(Phone,"Dialed *111#", testname);
                Phone.FindElement(By.Id("dialButton")).Click();
                //Dual Sim choose profile sim
                try
                {
                    Phone.FindElement(By.Id("select_account_list_item_view")).Click();
                }
                catch
                {
                   //if you dont have non Dual-sim it will skip this part
                }
                reports.Screenshot(Phone, "Dialer opened", testname);
            }
            finally
            {
                // Core.Close();
            }
        }
Beispiel #27
0
 public static bool IsElementPresent(string element, AndroidDriver driver)
 {
     try
     {
         driver.FindElement(By.Name(element));
         return(true); // Success!
     }
     catch (NoSuchElementException)
     {
         //Console.WriteLine("Error:" + element + " not displayed");
         return(false); // Do not throw exception
     }
 }
        /// <summary>
        /// Set account profile picture
        /// </summary>
        /// <param name="profilePicture">A valid http(s) jpg or png link</param>
        private AutomationResult ChangeProfilePicture(string profilePicture)
        {
            _logger.LogInformation($"Update profile picture: {profilePicture}");

            try
            {
                var extension  = new FileInfo(profilePicture).Extension.Replace(".", "");
                var photoBytes = new WebClient().DownloadData(profilePicture);

                // TODO: Check if the path is always the same
                _driver.PushFile($"/storage/emulated/0/DCIM/Camera/{Guid.NewGuid()}.{(string.IsNullOrWhiteSpace(extension) ? "jpg" : extension)}", photoBytes);

                _driver
                .FindElement(By.Id("com.instagram.android:id/profile_tab"))
                .Click();

                _driver
                .FindElement(By.Id("com.instagram.android:id/coordinator_root_layout"))
                .FindElements(By.ClassName("android.widget.Button"))
                .First(x => x.Text.ToLower().Contains("edit profile"))
                .Click();

                FindElement(By.Id("com.instagram.android:id/change_avatar_button")).Click();

                var hasActionSheetOpened = _driver.FindElement(By.Id("com.instagram.android:id/action_sheet_header_text_view")).Displayed;
                if (hasActionSheetOpened)
                {
                    _logger.LogInformation("First profile picture upload");
                    FindElement(By.XPath(@"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.TextView[1]")).Click();
                }
                else
                {
                    _logger.LogInformation("Profile picture upload");
                    FindElement(By.XPath("/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ListView/android.widget.FrameLayout[1]")).Click();
                }
                FindElement(By.Id("com.instagram.android:id/next_button_textview")).Click();
                FindElement(By.Id("com.instagram.android:id/next_button_textview")).Click();

                return(AutomationResult.Ok());
            }
            catch (Exception e)
            {
                return(AutomationResult.Error(e.Message));
            }
        }
        public Tuple <bool, IWebElement> AwaitElement(AndroidDriver <IWebElement> driver, string text, int sek = 20, string type = "TextView", string param = "text", string nameSpace = "android.widget")
        {
            var           by   = By.XPath("//" + nameSpace + "." + type + "[contains(@" + param + ", '" + text + "')]");
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(sek));

            try
            {
                wait.Until(ExpectedConditions.ElementExists(by));
                //wait.Until(ExpectedConditions.ElementIsVisible(by));
                return(new Tuple <bool, IWebElement>(true, driver.FindElement(by)));
            }
            catch
            {
                return(new Tuple <bool, IWebElement>(false, new Object() as IWebElement));
            }
        }
Beispiel #30
0
        public new void OneTimeSetup()
        {
            eyes_ = new Eyes();

            eyes_.MatchTimeout = TimeSpan.FromSeconds(10);
            eyes_.Batch        = TestDataProvider.BatchInfo;
            eyes_.SaveNewTests = false;
            driver_            = InitMobileDriverOnSauceLabs();
            //driver_ = InitMobileDriverOnBrowserStack();
            //driver_ = InitMobileDriverOnLocalDevice();

            IWebElement button = driver_.FindElement(buttonSelector_);

            button.Click();

            eyes_.CutProvider = cutProvider_;
        }