Example #1
0
        public static void OpenMusicPlayer()
        {
            try
            {
                Driver_Utilities.ClickElement(MusicPlayerMinimized);

                Console.Write("Opened the music player");
            }
            catch (Exception e)
            {
                Console.WriteLine("[ERROR]:\n" + e.Message);
                throw e;
            }
        }
Example #2
0
        public static void ClickOnSongOption(string SongName)
        {
            try
            {
                Driver_Utilities.ClickElement(By.XPath("//android.widget.TextView[@text=\"" + SongName + "\"]"));

                Console.WriteLine("Clicked on the song \"" + SongName + "\"");
            }
            catch (Exception e)
            {
                Console.WriteLine("[ERROR]:\n" + e.Message);
                throw e;
            }
        }
Example #3
0
        public static void NavigateToRockCatgory()
        {
            try
            {
                Driver_Utilities.ClickElement(GenresOption);
                Driver_Utilities.ClickElement(RockOption);

                Console.WriteLine("Navigated to the \"Rock\" category.");
            }
            catch (Exception e)
            {
                Console.WriteLine("[ERROR]:\n" + e.Message);
                throw e;
            }
        }
        public static void DeleteUsers(DataTable UsersTable)
        {
            try
            {
                //Delete user details:
                foreach (DataRow UserRow in UsersTable.Rows)
                {
                    //Search user by username before deletion:
                    Driver_Utilities.EnterText(SearchInput, UserRow["UserName"].ToString());

                    //Delete user:
                    Driver_Utilities.ClickElement(DeleteIcon);
                    Driver_Utilities.ClickElement(ConfirmationDialog_OK);
                }

                Console.WriteLine("Deleted all user(s) that has been created.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to delete user(s)");
                Console.WriteLine("[ERROR]:\n" + e.Message);
                throw e;
            }
        }
        public static void AddUsers(DataTable UsersTable)
        {
            try
            {
                //Create users:
                foreach (DataRow UserRow in UsersTable.Rows)
                {
                    //Open add user menu:
                    Driver_Utilities.ClickElement(AddUserButton);

                    //Enter user details:
                    Driver_Utilities.EnterText(FirstNameInput, UserRow["FirstName"].ToString());
                    Driver_Utilities.EnterText(LastNameInput, UserRow["LastName"].ToString());

                    //Generate GUID and append first 8 characters to username for a unique username:
                    Guid guid = Guid.NewGuid();
                    Driver_Utilities.EnterText(UserNameInput, UserRow["UserName"].ToString() + "-" + guid.ToString().Substring(0, 7));
                    Driver_Utilities.EnterText(PasswordInput, UserRow["Password"].ToString());

                    switch (UserRow["Customer"].ToString().ToLower())
                    {
                    case "company aaa":
                        Driver_Utilities.ClickElement(CompanyAAARadioButton);
                        break;

                    case "company bbb":
                        Driver_Utilities.ClickElement(CompanyBBBRadioButton);
                        break;

                    default:
                        throw new Exception("Failed to select customer type");
                    }

                    switch (UserRow["Role"].ToString().ToLower())
                    {
                    case "sales team":
                        Driver_Utilities.ClickElement(RoleDropDown(0));
                        break;

                    case "customer":
                        Driver_Utilities.ClickElement(RoleDropDown(1));
                        break;

                    case "admin":
                        Driver_Utilities.ClickElement(RoleDropDown(2));
                        break;

                    default:
                        throw new Exception("Failed to select Role");
                    }

                    Driver_Utilities.EnterText(EmailInput, UserRow["EMail"].ToString());
                    Driver_Utilities.EnterText(CellPhoneInput, UserRow["CellPhone"].ToString());

                    Console.WriteLine("Entered user details.");

                    Driver_Utilities.ClickElement(SaveButton);
                }

                Console.WriteLine("Created user account(s)");
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to create a user(s)");
                Console.WriteLine("[ERROR]:\n" + e.Message);
                throw e;
            }
        }