Example #1
0
        /// <summary>
        /// Attempts to log in
        /// </summary>
        /// <returns>false if failed to log in, not if already logged in</returns>
        public bool LogIn()
        {
            Console.WriteLine("Logging in  if can");
            WebDriverWait wait = TestingConfig.GetWaitDriver(Driver);

            try
            {
                //if we are logged in we are done
                if (IsLoggedOut())
                {
                    return(false);
                }
                LoginButton.Click();

                LogInPage loginpage = new LogInPage(Driver);

                Console.WriteLine("Navigating to login page");
                wait.Until(dr => loginpage.LogoButton);
                loginpage.LogIn();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(false);
            }
            return(true);
        }
Example #2
0
 /// <summary>
 /// Attempts to log out
 /// </summary>
 /// <returns>false if failed to logout, not if already logged out</returns>
 public bool LogOut()
 {
     Console.WriteLine("Logging out  if can");
     try
     {
         if (IsLoggedIn())
         {
             return(true);
         }
         WebDriverWait wait = TestingConfig.GetWaitDriver(Driver);
         UserDropDown.Click();
         wait.Until(dr => SignOutButton);
         SignOutButton.Click();
         wait.Until(dr => HomeButton);
         HomeButton.Click();
         wait.Until(dr => LoginButton);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
         Console.WriteLine("Cannot log out");
         return(false);
     }
     return(true);
 }
Example #3
0
    /*
     *  ////////////////////////////////////////////////////////////////////////////////////////////////
     *  // Testing token refresh
     *  //
     *  // NOTE: this test takes an hour, so it's disabled by default. Change false to true to run.
     *  ////////////////////////////////////////////////////////////////////////////////////////////////
     */
    public static void TestTokenRefresh()
    {
        TestingConfig config = new TestingConfig();
        APIConnection api    = config.Connection;

        string oldToken = api.GetToken();

        Console.WriteLine("Old token: " + oldToken);

        api.GET("/departments");

        // Wait 3600 seconds = 1 hour for token to expire.
        Thread.Sleep(3600 * 1000);

        api.GET("/departments");

        Console.WriteLine("New token: " + api.GetToken());
    }
Example #4
0
        public override void RunBaseTests()
        {
            base.RunBaseTests();

            Console.WriteLine("nav bar base tests");

            Console.WriteLine("Allways on buttons");
            Assert.IsTrue(NewPostButton.Displayed, "New post button not visible");
            Assert.IsTrue(TopCommentsButton.Displayed, "top comments button not visible");
            Assert.IsTrue(HomeButton.Displayed, "Home button not visible");

            LogOut();
            Console.WriteLine("Is logged out buttons not visible");
            Assert.IsTrue(LoginButton.Displayed, "loggin button not visible");
            Assert.IsTrue(SignUpButton.Displayed, "signup button not visible");

            LogIn();

            Console.WriteLine("Is Logged in buttons not visible");
            Assert.IsTrue(MessagesButton.Displayed, "Messages button not visible");
            Assert.IsTrue(NotificationsButton.Displayed, "Notifications button not visible");
            Assert.IsTrue(UserDropDown.Displayed, "user options dropdown button not visible");

            WebDriverWait wait = TestingConfig.GetWaitDriver(Driver);

            UserDropDown.Click();
            wait.Until(dr => PostsButton.Displayed);
            Assert.IsTrue(PostsButton.Displayed, "User posts button not visible");
            Assert.IsTrue(FavoritesButton.Displayed, "User favorites button not visible");
            Assert.IsTrue(CommentsButton.Displayed, "Comments button not visible");
            Assert.IsTrue(AboutButton.Displayed, "About button not visible");
            Assert.IsTrue(ImagesButton.Displayed, "Images button not visible");
            Assert.IsTrue(AlbumsButton.Displayed, "Albums button not visible");
            Assert.IsTrue(SettingsButton.Displayed, "settings button not visible");
            Assert.IsTrue(SignOutButton.Displayed, "Signout button not visible");
        }
Example #5
0
    static public void Main()
    {
        TestingConfig config = new TestingConfig();
        APIConnection api    = config.Connection;

        // If you want to set the practice ID after construction, this is how.
        // api.PracticeID = "000000";


        ////////////////////////////////////////////////////////////////////////////////////////////////
        // GET without parameters
        ////////////////////////////////////////////////////////////////////////////////////////////////
        dynamic customfields = api.GET("/customfields");

        Console.WriteLine("Custom fields:");
        foreach (dynamic field in customfields)
        {
            Console.WriteLine("\t" + field["name"]);
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////
        // GET with parameters
        ////////////////////////////////////////////////////////////////////////////////////////////////
        string   format   = "MM/dd/yyyy";
        DateTime today    = DateTime.Now;
        DateTime nextyear = today.AddYears(1);

        Dictionary <string, string> search = new Dictionary <string, string>()
        {
            { "departmentid", "82" },
            { "startdate", today.ToString(format) },
            { "enddate", nextyear.ToString(format) },
            { "appointmenttypeid", "2" },
            { "limit", "1" },
        };

        dynamic open_appts = api.GET("/appointments/open", search);

        Console.WriteLine(open_appts.ToString());
        dynamic appt = open_appts["appointments"][0];

        Console.WriteLine("Open appointment:");
        Console.WriteLine(appt.ToString());

        Dictionary <string, string> newAppt = new Dictionary <string, string>();

        foreach (KeyValuePair <string, dynamic> kvp in appt)
        {
            newAppt[kvp.Key] = kvp.Value.ToString();
        }


        // add keys to make appt usable for scheduling
        appt["appointmenttime"] = appt["starttime"];
        appt["appointmentdate"] = appt["date"];


        // Thread.Sleep(1000);      // NOTE: Uncomment this line if you keep getting "Over QPS" errors
        ////////////////////////////////////////////////////////////////////////////////////////////////
        // POST with parameters
        ////////////////////////////////////////////////////////////////////////////////////////////////
        Dictionary <string, string> patientInfo = new Dictionary <string, string>()
        {
            { "departmentid", "1" },
            { "lastname", "Foo" },
            { "firstname", "Jason" },
            { "address1", "123 Any Street" },
            { "city", "Cambridge" },
            { "countrycode3166", "US" },
            { "dob", "6/18/1987" },
            { "language6392code", "declined" },
            { "maritalstatus", "S" },
            { "race", "declined" },
            { "sex", "M" },
            { "ssn", "*****1234" },
            { "zip", "02139" },
        };

        dynamic newPatient = api.POST("/patients", patientInfo);

        Console.WriteLine(newPatient.ToString());
        string newPatientID = newPatient[0]["patientid"];

        Console.WriteLine("New patient id:");
        Console.WriteLine(newPatientID);


        ////////////////////////////////////////////////////////////////////////////////////////////////
        // PUT with parameters
        ////////////////////////////////////////////////////////////////////////////////////////////////
        Dictionary <string, string> appointmentInfo = new Dictionary <string, string>()
        {
            { "appointmenttypeid", "82" },
            { "departmentid", "1" },
            { "patientid", newPatientID },
        };

        dynamic booked = api.PUT("/appointments/" + appt["appointmentid"], appointmentInfo);

        Console.WriteLine("Booked:");
        Console.WriteLine(booked.ToString());


        // Thread.Sleep(1000);      // NOTE: Uncomment this line if you keep getting "Over QPS" errors
        ////////////////////////////////////////////////////////////////////////////////////////////////
        // POST without parameters
        ////////////////////////////////////////////////////////////////////////////////////////////////
        dynamic checked_in = api.POST(string.Format("/appointments/{0}/checkin", appt["appointmentid"]));

        Console.WriteLine("Check-in:");
        Console.WriteLine(checked_in.ToString());


        ////////////////////////////////////////////////////////////////////////////////////////////////
        // DELETE with parameters
        ////////////////////////////////////////////////////////////////////////////////////////////////
        Dictionary <string, string> deleteParams = new Dictionary <string, string>()
        {
            { "departmentid", "1" },
        };
        dynamic chartAlert = api.DELETE(string.Format("/patients/{0}/chartalert", newPatientID), deleteParams);

        Console.WriteLine("Removed chart alert:");
        Console.WriteLine(chartAlert.ToString());


        ////////////////////////////////////////////////////////////////////////////////////////////////
        // DELETE without parameters
        ////////////////////////////////////////////////////////////////////////////////////////////////
        dynamic photo = api.DELETE(string.Format("/patients/{0}/photo", newPatientID));

        Console.WriteLine("Removed photo:");
        Console.WriteLine(photo.ToString());


        ////////////////////////////////////////////////////////////////////////////////////////////////
        // There are no PUTs without parameters
        ////////////////////////////////////////////////////////////////////////////////////////////////


        // Thread.Sleep(1000);      // NOTE: Uncomment this line if you keep getting "Over QPS" errors
        ////////////////////////////////////////////////////////////////////////////////////////////////
        // Error conditions
        ////////////////////////////////////////////////////////////////////////////////////////////////
        dynamic badPath = api.GET("/nothing/at/this/path");

        Console.WriteLine("GET /nothing/at/this/path:");
        Console.WriteLine(badPath.ToString());
        dynamic missingParameters = api.GET("/appointments/open");

        Console.WriteLine("Missing parameters:");
        Console.WriteLine(missingParameters.ToString());
    }