public static void ClickRefill(RemoteWebDriver driver) { do { Console.WriteLine("Wait for 5 seconds medications page to open " + PerfectoHooks.CurrentDevice.DeviceDetails.Name); Thread.Sleep(5000); } while (PerfectoUtils.OCRTextCheckPoint(driver, "Retrieving", 6)); if (PerfectoUtils.IsTablet()) { PerfectoUtils.OCRTextClick(driver, "Refill a prescription", 90, 20, 1, false, 1, false); } else { driver.FindElementByXPath(RefillMedicationButton).Click(); } PerfectoUtils.RotateDevice(driver, Constants.Rotation.LANDSCAPE); Thread.Sleep(1000); PerfectoUtils.RotateDevice(driver, Constants.Rotation.PORTRAIT); Thread.Sleep(1000); PerfectoUtils.RotateDevice(driver, Constants.Rotation.LANDSCAPE); Thread.Sleep(1000); PerfectoUtils.RotateDevice(driver, Constants.Rotation.PORTRAIT); Thread.Sleep(1000); }
public void GivenPopup(string action, string popupName) { //driver.Context = Constants.VISUAL; if (Checkpoint(popupName, driver, 20)) { PerfectoUtils.OCRTextClick(driver, action, 90, 20, 2); Thread.Sleep(1000); } }
protected static void CloseApp(string appName) { try { PerfectoUtils.CloseApp(driver, appName); } catch (Exception e) { Console.WriteLine("Close App Failed: " + e.Message); } }
public void GivenIAmALoggedInUser() { if (PerfectoUtils.OCRTextCheckPoint(driver, "Patient", 6)) { return; } SignInPage.ClickStartSignIn(driver); if (PerfectoUtils.OCRTextCheckPoint(driver, "Patient", 6)) { return; } SignInPage.SignIn(driver); }
public static void ClickStartSignIn(AppiumDriver <IWebElement> driver) { //PerfectoUtils.OCRTextClick(driver, "Sign In", 90, 20, 1, false, 0, true); driver.Context = Constants.NATIVEAPP; driver.FindElementByXPath(StartSignInButton).Click(); Thread.Sleep(2000); //sometimes an authenticating modal appears - if so, give it some time to breath Console.WriteLine("Looking for Authenticating modal " + PerfectoHooks.CurrentDevice.DeviceDetails.Name); if (PerfectoUtils.OCRTextCheckPoint(driver, "Authenticating", 6, true)) { Console.WriteLine("Found Authenticating modal, sleep for few seconds" + PerfectoHooks.CurrentDevice.DeviceDetails.Name); Thread.Sleep(4000); } }
public static void SignIn(AppiumDriver <IWebElement> driver) { driver.Context = Constants.NATIVEAPP; driver.FindElementByXPath(UsernameField).Clear(); driver.FindElementByXPath(UsernameField).SendKeys(Constants.MAYO_USERNAME); driver.FindElementByXPath(PasswordField).SendKeys(Constants.MAYO_PASSWORD); Thread.Sleep(1000); if (PerfectoUtils.IsiPad()) { if (PerfectoUtils.OCRTextCheckPoint(driver, "Privacy policy", 6, false)) { driver.FindElementByXPath(PrivacyPolicySwitch).Click(); Thread.Sleep(2000); } } driver.FindElementByXPath(SignInButton).Click(); }
public static void ClickPatient(AppiumDriver <IWebElement> driver) { //Ipad has no home page if (PerfectoUtils.IsiPad()) { return; } if (PerfectoUtils.IsTablet()) { Console.WriteLine("About to click patient link - sleep for tablet " + PerfectoHooks.CurrentDevice.DeviceDetails.Name); Thread.Sleep(15000); } driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(25)); driver.FindElementByXPath(PatientButton).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(6)); //App sends to authenticate if haven't already authenticated after opening app try { if (driver.FindElementsByXPath(UsernameField).Count > 0) { Console.WriteLine("Redirected to sign in - attempt sign in " + PerfectoHooks.CurrentDevice.DeviceDetails.Name); SignInPage.SignIn(driver); } { Console.WriteLine("login screen not found " + PerfectoHooks.CurrentDevice.DeviceDetails.Name); } } catch (Exception) { } driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(15)); }
/// <summary> /// A text checkpoint using perfecto's extended mobile:checkpoint:text command. /// </summary> /// <param name="textToFind">The needle text you are looking for in your haystack.</param> /// <param name="timeoutInSeconds">Timeout in seconds.</param> /// <returns>Bool indicating if the text was found.</returns> protected static bool Checkpoint(string textToFind, AppiumDriver <IWebElement> driver, int?timeoutInSeconds = 25) { Console.WriteLine(string.Format("Checking text {0}", textToFind)); return(PerfectoUtils.OCRTextCheckPoint(driver, textToFind, timeoutInSeconds ?? 25)); }
public void GivenIClick(string buttonName, string pageName) { Thread.Sleep(2000); switch (pageName) { case "Popup": switch (buttonName) { case "OK": if (Checkpoint("OK", driver, 20)) { driver.Context = Constants.NATIVEAPP; driver.FindElementByXPath("//*[@resource-id='android:id/button1']").Click(); } break; case "Yes": if (Checkpoint("Yes", driver, 20)) { driver.Context = Constants.NATIVEAPP; driver.FindElementByXPath("//*[@resource-id='android:id/button1']").Click(); } break; case "No": if (Checkpoint("No", driver, 20)) { driver.Context = Constants.NATIVEAPP; driver.FindElementByXPath("//*[@resource-id='android:id/button2']").Click(); } break; case "Allow": PerfectoUtils.OCRTextClick(driver, "Allow", 90, 20, 2); break; case "Cancel": PerfectoUtils.OCRTextClick(driver, "Cancel", 90, 20, 1); break; default: break; } break; case "Home": switch (buttonName) { //case "Patient": // PerfectoUtils.OCRTextClick(driver, "Patient", 90, 20, 1); // Thread.Sleep(2000); // break; case "Patient": driver.Context = Constants.NATIVEAPP; HomePage.ClickPatient(driver); break; default: break; } break; case "Patient": switch (buttonName) { case "???": driver.Context = Constants.NATIVEAPP; //PatientPage.; break; default: break; } break; case "Patient Menu": switch (buttonName) { case "Medications": PatientMenuPage.ValidateOnPatientHeader(driver); PatientMenuPage.GoToMedicationPage(driver); break; default: break; } break; case "Medications": switch (buttonName) { case "Refill a Prescription": driver.Context = Constants.NATIVEAPP; MedicationPage.ClickRefill(driver); break; } break; //case "Navigation": // switch (buttonName) // { // case "Menu": // Navigation.ClickMenu(driver); // break; // case "Store Locator": // PerfectoUtils.OCRTextClick(driver, "Complete", 90, 20, 1); // Thread.Sleep(2000); // Navigation.ClickStoreLocator(driver); // break; // default: // break; // } // break; case "ExtraCare Card": switch (buttonName) { case "View My Deals & Rewards": driver.FindElementByXPath("//*[@resource-id='com.cvs.launchers.cvs:id/showDealsDragDowntv']").Click(); break; default: break; } break; case "Your Deals & Rewards": switch (buttonName) { case "Remove ExtraCare Card": PerfectoUtils.Swipe(driver, "50%,80%", "50%,30%"); Thread.Sleep(1000); PerfectoUtils.Swipe(driver, "50%,80%", "50%,30%"); Thread.Sleep(1000); PerfectoUtils.Swipe(driver, "50%,80%", "50%,30%"); Thread.Sleep(1000); PerfectoUtils.Swipe(driver, "50%,80%", "50%,30%"); Thread.Sleep(1000); PerfectoUtils.OCRTextClick(driver, "Remove ExtraCare Card", 90, 0, 1, true); Thread.Sleep(1000); break; default: break; } break; default: break; } Thread.Sleep(1000); }