コード例 #1
0
 private static AndroidElement GetPropertyItem(string propertyName)
 {
     try
     {
         AndroidElement propItem = null;
         ReadOnlyCollection <AppiumWebElement> propertyItems = PropertyList.GetInternalElement().FindElementsByClassName("android.widget.RelativeLayout");
         foreach (var element in propertyItems)
         {
             string currPropName = element.FindElementById("property_name").Text;
             if (currPropName.Contains(propertyName))
             {
                 propItem = (AndroidElement)element;
                 return(propItem);
             }
         }
         Assert.Fail("Can't find property with name: " + propertyName);
         return(null);
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(
             String.Format(
                 "{0}. Can't find property.", ActivityName), ex);
         throw;
     }
 }
コード例 #2
0
        public static void VerifyFroupRow(int groupNum, int expectedRow)
        {
            try
            {
                //get drag item
                var root         = Appium.Instance.Driver.FindElementById("groups_grid");
                var groupList    = root.FindElementsById("table");
                int currentCount = groupList[groupNum].FindElementsByClassName("android.widget.TableRow").Count - 1;
                Assert.AreEqual(expectedRow, currentCount,
                                "Current table count: " + currentCount + " not equal to expected: " + expectedRow);



                ConsoleMessage.Pass(
                    String.Format(
                        "{0}. Verify row count in group at position: {1}, expected count: {2}",
                        ActivityName, groupNum, expectedRow));
            }
            catch (Exception ex)
            {
                ConsoleMessage.Fail(
                    String.Format(
                        String.Format(
                            "{0}. Can't Verify row count in group at position: {1}, expected count: {2}",
                            ActivityName, groupNum, expectedRow)), ex);
                throw;
            }
        }
コード例 #3
0
        public static void VerifyLogin(int timeout)
        {
            string    expectedActivity     = ".ProjectsBrowserActivity";
            double    timeOutInMillSeconds = TimeSpan.FromSeconds(timeout).TotalMilliseconds;
            Stopwatch sw = new Stopwatch();

            try
            {
                sw.Start();
                while (sw.ElapsedMilliseconds < timeOutInMillSeconds)
                {
                    if (Appium.Instance.Driver.CurrentActivity == expectedActivity)
                    {
                        sw.Stop();
                        ConsoleMessage.Pass(String.Format("{0}. Login success. Login time: {1}",
                                                          ActivityName, TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds).TotalSeconds));
                        return;
                    }
                }
                Assert.Fail("{0}. Login timeout: {1} sec.", ActivityName, timeout);
            }
            catch (Exception ex)
            {
                ConsoleMessage.Fail(String.Format("{0}. Can't Login",
                                                  ActivityName), ex);
                throw;
            }
        }
コード例 #4
0
 public static void SetPermission(Permission permission)
 {
     try
     {
         if (permission.View)
         {
             Appium.Instance.Driver.FindElementById("chk_view").Click();
         }
         if (permission.Share)
         {
             Appium.Instance.Driver.FindElementById("chk_share").Click();
         }
         if (permission.Modify)
         {
             Appium.Instance.Driver.FindElementById("chk_modify").Click();
         }
         if (permission.Add)
         {
             Appium.Instance.Driver.FindElementById("chk_add").Click();
         }
         ConsoleMessage.Pass(String.Format("{0}. Set permission", ActivityName));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't set permission", ActivityName), ex);
         throw;
     }
 }
コード例 #5
0
 public static void DeleteAllLibs()
 {
     try
     {
         string standard = "Standard";
         ReadOnlyCollection <AppiumWebElement> libList =
             LibraryList.GetInternalElement().FindElementsById("library_row_layout");
         int shift = 0;
         while (libList.Count > 1)
         {
             string libName = libList[shift].FindElementById("library_title").Text;
             if (libName == standard)
             {
                 shift++;
             }
             ConsoleMessage.Pass(String.Format("{0}. Select library with name: {1}", ActivityName, libName));
             libList[shift].Click();
             DeleteLibrary.Tap();
             LibraryDeleteDialog.Delete.Tap();
             libList =
                 LibraryList.GetInternalElement().FindElementsById("library_row_layout");
         }
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't delete all libraries: {1}", ActivityName), ex);
         throw;
     }
 }
コード例 #6
0
 public static void VerifyCantShareLibrary(string libraryName)
 {
     try
     {
         ReadOnlyCollection <AppiumWebElement> libList =
             LibraryList.GetInternalElement().FindElementsById("library_row_layout");
         foreach (var element in libList)
         {
             if (element.FindElementById("library_title").Text == libraryName)
             {
                 element.Click();
                 element.FindElementById("chkLibrary").Click();
                 CommonOperation.Delay(1);
                 Assert.False(Boolean.Parse(element.FindElementById("chkLibrary").GetAttribute("checked")),
                              "Can check " + libraryName + " checkbox without share permission");
                 ConsoleMessage.Pass(String.Format("{0}. Can't Checked library for share with name: {1} without permission", ActivityName, libraryName));
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can checked library for share with name: {1} without permission", ActivityName, libraryName), ex);
         throw;
     }
 }
コード例 #7
0
        public static void ClickOnPropertyCheckbox(string propName)
        {
            try
            {
                var propList = PropertyList.GetInternalElement().FindElementsByClassName("android.widget.TableRow");
                foreach (var element in propList)
                {
                    string currProp = element.FindElementByClassName("android.widget.TextView").Text;
                    if (currProp.Contains(propName))
                    {
                        element.FindElementByClassName("android.widget.CheckBox").Click();
                        break;
                    }
                }


                ConsoleMessage.Pass(String.Format("{0}. Tap on checkbox on property with name: {1}",
                                                  ActivityName, propName));
            }
            catch (Exception ex)
            {
                ConsoleMessage.Fail(String.Format("{0}. Can't tap on checkbox on property with name: {1}",
                                                  ActivityName, propName), ex);
                throw;
            }
        }
コード例 #8
0
 public static void DeleteAllFlows()
 {
     try
     {
         var flowList = FlowList.GetInternalElement().FindElementsById("browser_element_name");
         while (flowList.Count > 0)
         {
             string flowName = flowList[0].Text;
             flowList[0].Click();
             ConsoleMessage.Pass(String.Format("{0}. Click on flow with name: {1}",
                                               ActivityName, flowName));
             FlowActivity.DeleteFlow.Tap();
             FlowDeleteDialog.Delete.Tap();
             flowList = FlowList.GetInternalElement().FindElementsById("browser_element_name");
         }
         ConsoleMessage.Pass(String.Format("{0}. Delete all flow in current assay",
                                           ActivityName));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't delete all flow in current assay",
                                           ActivityName), ex);
         throw;
     }
 }
コード例 #9
0
        public static void MoveFromNotInGroupToGroup(int pickRow, int toGroup, int dropRow)
        {
            try
            {
                AndroidElement dragItem = null;
                AndroidElement dropItem = null;
                //get drag item
                var root      = Appium.Instance.Driver.FindElementById("groups_grid");
                var groupList = root.FindElementsById("table");
                dropItem =
                    (AndroidElement)groupList[toGroup].FindElementsByClassName("android.widget.TableRow")[dropRow];
                //get drop item
                dragItem = (AndroidElement)NotInGroupList.GetInternalElement().FindElementsById("row_layout")[pickRow];
                //drag n drop
                TouchAction action = new TouchAction(Appium.Instance.Driver);
                action.Press(dragItem).Wait(1500).MoveTo(dragItem).MoveTo(dropItem).Release().Perform();

                ConsoleMessage.Pass(
                    String.Format(
                        "{0}. Take row at position: {1} from group not in group and drop to group at position: {2} at row: {3}",
                        ActivityName, pickRow, toGroup, dropRow));
            }
            catch (Exception ex)
            {
                ConsoleMessage.Fail(
                    String.Format(
                        String.Format(
                            "{0}. Can't take row at position: {1} from group not in group and drop to group at position: {2} at row: {3}",
                            ActivityName, pickRow, toGroup, dropRow)), ex);
                throw;
            }
        }
コード例 #10
0
 public static void OpenElement(string elementName)
 {
     try
     {
         var elementList = ElementList.GetInternalElement().FindElementsByClassName("android.widget.EditText");
         for (int i = 0; i < elementList.Count; i++)
         {
             var element = elementList[i];
             if (element.Text.Contains(elementName))
             {
                 ElementList.GetInternalElement().FindElementsById("document_icon")[i].Click();
                 break;
             }
         }
         ConsoleMessage.Pass(String.Format("{0}. Find and tap on flow element with name: {1} in flow list",
                                           ActivityName, elementName));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(
             String.Format("{0}. Can't Find and tap on flow element with name: {1} in flow list",
                           ActivityName, elementName), ex);
         throw;
     }
 }
コード例 #11
0
 public static void SelectFlowPlan()
 {
     try
     {
         FlowType.GetInternalElement().FindElementByName("Flow Plan").Click();
         ConsoleMessage.Pass(String.Format("{0}. Select: Flow Plan", ActivityName));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't Select: Flow Plan", ActivityName), ex);
         throw;
     }
 }
コード例 #12
0
 public static void VerifyLibraryNotExist(string libraryName)
 {
     try
     {
         Assert.True(LibraryList.GetInternalElement().FindElementsByName(libraryName).Count == 0, "Library with name: " + libraryName + " exist");
         ConsoleMessage.Pass(String.Format("{0}. Verify, library with name: {1} not exist", ActivityName, libraryName));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Verify fail. Library with name: {1} still exist", ActivityName, libraryName), ex);
         throw;
     }
 }
コード例 #13
0
 public static void OpenProperty(string propertyName)
 {
     try
     {
         GetPropertyItem(propertyName).Click();
         ConsoleMessage.Pass(
             String.Format("{0}. Open property with name: {1}", ActivityName, propertyName));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(
             String.Format("{0}. Can't open property with name: {1}", ActivityName, propertyName), ex);
         throw;
     }
 }
コード例 #14
0
 protected BaseAndroidElement(string elementName, string activityName)
 {
     ElementName = elementName;
     try
     {
         Element      = Appium.Instance.Driver.FindElementByName(ElementName);
         ActivityName = activityName;
         ElementId    = "No id";
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't find element with name: {1}", ActivityName, ElementName), ex);
         throw;
     }
 }
コード例 #15
0
 public void Tap()
 {
     try
     {
         Element.Click();
         ConsoleMessage.Pass(String.Format("{0}. Tap on button with name: {1}",
                                           ActivityName, ElementName));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't tap on button with name: {1} and android id: {2}",
                                           ActivityName, ElementName, ElementId), ex);
         throw;
     }
 }
コード例 #16
0
 public static void TapOnFlowElement(int position)
 {
     try
     {
         ElementList.GetInternalElement().FindElementsById("document_icon")[position].Click();
         ConsoleMessage.Pass(String.Format("{0}. Tap flow element by position: {1}",
                                           ActivityName, position));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Tap flow element by position: {1}",
                                           ActivityName, position), ex);
         throw;
     }
 }
コード例 #17
0
 public static void SearchItem(string name)
 {
     try
     {
         Appium.Instance.Driver.FindElementById("search_src_text").SendKeys(name + "\n");
         ConsoleMessage.Pass(String.Format("{0}. Find search textbox and enter searched name: {1}",
                                           ActivityName, name));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(
             String.Format("{0}. Can't find search textbox and enter searched name: {1}", ActivityName, name), ex);
         throw;
     }
 }
コード例 #18
0
 protected BaseAndroidElement(AndroidElement element, string activityName)
 {
     try
     {
         Element      = element;
         ElementName  = "No Name";
         ActivityName = activityName;
         ElementId    = "No id";
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't find element", ActivityName), ex);
         throw;
     }
 }
コード例 #19
0
 public static void DeleteProperty(string propertyName)
 {
     try
     {
         GetPropertyItem(propertyName).FindElementById("property_delete").Click();
         ConsoleMessage.Pass(
             String.Format("{0}. Click delete property: {1}", ActivityName, propertyName));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(
             String.Format("{0}. Can't click delete property: {1}", ActivityName, propertyName), ex);
         throw;
     }
 }
コード例 #20
0
 public static void VerifyFlowNotExist(string flowName)
 {
     try
     {
         Assert.True(FlowList.GetInternalElement().FindElementsByName(flowName).Count == 0,
                     String.Format("Flow with name: {0} still exist", flowName));
         ConsoleMessage.Pass(String.Format("{0}. Verify, flow with name: {1} not exist",
                                           ActivityName, flowName));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't verify. Flow with name: {1}  exist",
                                           ActivityName, flowName), ex);
         throw;
     }
 }
コード例 #21
0
 public static void AddUserToTeam(string userName)
 {
     try
     {
         AndroidElement dragItem = UserList.FindElement(userName);
         AndroidElement dropItem = TeamMemberList.GetInternalElement();
         TouchAction    action   = new TouchAction(Appium.Instance.Driver);
         action.Press(dragItem).Wait(1500).MoveTo(dropItem).Release().Perform();
         ConsoleMessage.Pass(String.Format("{0}. Drag user with name: {1} and drop to team", ActivityName, userName));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't drag user with name: {1} and drop to team", ActivityName, userName), ex);
         throw;
     }
 }
コード例 #22
0
 public static void RestoreAtPosition(int row)
 {
     try
     {
         DeletedList.GetInternalElement().FindElementsById("deletedRow")[row].FindElementById("restore_button")
         .Click();
         ConsoleMessage.Pass(String.Format("{0}. Click restore button on #row: {1}",
                                           ActivityName, row));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't click restore button on #row: {1}",
                                           ActivityName, row), ex);
         throw;
     }
 }
コード例 #23
0
 public static void TapByCoordinate(int x, int y)
 {
     try
     {
         TouchAction action = new TouchAction(Appium.Instance.Driver);
         action.Press(x, y).Release().Perform();
         ConsoleMessage.Pass(
             String.Format("{0}. Tap by coordinate. Point[x: {1}, y:{2} ]", ActivityName, x, y));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(
             String.Format("{0}. Tap by coordinate. Point[x: {1}, y:{2} ]", ActivityName, x, y), ex);
         throw;
     }
 }
コード例 #24
0
 public static void OpenElement(int pos)
 {
     try
     {
         ElementList.GetInternalElement().FindElementsById("document_icon")[pos].Click();
         ConsoleMessage.Pass(String.Format("{0}. Find and tap on flow element at position: {1} in flow list",
                                           ActivityName, pos));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(
             String.Format("{0}. Find and tap on flow element at position: {1} in flow list",
                           ActivityName, pos), ex);
         throw;
     }
 }
コード例 #25
0
 public static void VerifyPropertyMarkAsRequired(string propertyName)
 {
     try
     {
         Assert.Greater(GetPropertyItem(propertyName).FindElementsById("property_required").Count, 0,
                        "Can't find required mark on property: " + propertyName);
         ConsoleMessage.Pass(
             String.Format("{0}. Verify, property with name: {1} marked as required", ActivityName, propertyName));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(
             String.Format("{0}. Can't verify, property with name: {1} marked as required", ActivityName, propertyName), ex);
         throw;
     }
 }
コード例 #26
0
 public static void VerifyGroupIsHide()
 {
     try
     {
         var rowList = TableList.GetInternalElement().FindElementsById("row_layout");
         Assert.IsTrue(rowList[0].FindElementsById("group_text").Count == 0, "Group is still shows");
         ConsoleMessage.Pass(String.Format("{0}. Verify, group is hide",
                                           ActivityName));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't verify, group is not hide",
                                           ActivityName), ex);
         throw;
     }
 }
コード例 #27
0
 public void EnterText(string text)
 {
     try
     {
         Element.Click();
         Element.SendKeys(text);
         CommonOperation.HideKeyboard();
         ConsoleMessage.Pass(String.Format("{0}. Enter text in textbox with name: {1}, Text: {2}",
                                           ActivityName, ElementName, text));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't enter text in textbox with name: {1} and android id: {2}",
                                           ActivityName, ElementName, ElementId), ex);
         throw;
     }
 }
コード例 #28
0
 public static void VerifyElementMarkAsBlocked(int position)
 {
     try
     {
         var currentText = ElementList.GetInternalElement().FindElementsById("document_name")[position].Text;
         Assert.True(String.IsNullOrEmpty(currentText),
                     "Current element text name: " + currentText + " but should be empty");
         ConsoleMessage.Pass(String.Format("{0}. Verify, element at position: {1} is blocked",
                                           ActivityName, position));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't verify element at position: {1} is blocked",
                                           ActivityName, position), ex);
         throw;
     }
 }
コード例 #29
0
 public void ClearText()
 {
     try
     {
         Element.Click();
         Element.Clear();
         CommonOperation.HideKeyboard();
         ConsoleMessage.Pass(String.Format("{0}. Clear text in textbox with name: {1}",
                                           ActivityName, ElementName));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't clear text in textbox with name: {1} and android id: {2}",
                                           ActivityName, ElementName, ElementId), ex);
         throw;
     }
 }
コード例 #30
0
 public static void FindAndTap(string element)
 {
     try
     {
         Appium.Instance.Driver.FindElementByClassName("android.widget.ListView")
         .FindElementByName(element)
         .Click();
         ConsoleMessage.Pass(String.Format("{0}. Find element with name: {1} and select",
                                           ActivityName, element));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't find element with name: {1} and select",
                                           ActivityName, element), ex);
         throw;
     }
 }