Ejemplo n.º 1
0
def ApplyFilter(strFilterOn):
    if (strFilterOn == 'Username'):
        lstColUsername = GetRowData(strFilterOn)
        strFilterValue = Helper.SelectRandomValueFromList(lstColUsername)
        WebObjUserName = Users.UserName()
        Sys.Desktop.Keys(strFilterValue)

    if (strFilterOn == 'User Role'):
        WebObjUserType = Users.UserType()
        listFilterValues = Helper.ConvertStringIntoList(
            WebObjUserType.wItemList, ";")
        strFilterValue = Helper.SelectRandomValueFromList(listFilterValues)
        WebObjUserType.ClickItem(strFilterValue)
        if (WebObjUserType.wText == strFilterValue):
            Log.Checkpoint("Selected Value From {" + strFilterOn +
                           "} Dropdown is: " + WebObjUserType.wText)
        else:
            Log.Error("Unable To Select Value {" + strFilterValue +
                      "} from {" + strFilterOn + "} Dropdown")

    if (strFilterOn == 'Employee Name'):
        WebObjEmployeeName = Users.EmployeeName()
        lstEmpName = GetRowData(strFilterOn)
        strFilterValue = Helper.SelectRandomValueFromListWithExclusion(
            lstEmpName, '')
        Sys.Desktop.Keys(strFilterValue)
        WebObjEmployeeNameList = Users.EmployeeNameList(strFilterValue)
        WebObjEmployeeNameList.Click()

    if (strFilterOn == 'Status'):
        WebObjUserStatus = Users.UserStatus()
        listFilterValues = Helper.ConvertStringIntoList(
            WebObjUserStatus.wItemList, ";")
        strFilterValue = Helper.SelectRandomValueFromList(listFilterValues)
        WebObjUserStatus.ClickItem(strFilterValue)
        if (WebObjUserStatus.wText == strFilterValue):
            Log.Checkpoint("Selected Value From {" + strFilterOn +
                           "} Dropdown is: " + WebObjUserStatus.wText)
        else:
            Log.Error("Unable To Select Value {" + strFilterValue +
                      "} from {" + strFilterOn + "} Dropdown")

    if (strFilterValue == 'All'):
        preFilterRowCount = GetRowCount(strFilterOn)
        WebObjSearch = Users.Search()
        WebObjSearch.Click()
        postFilterRowCount = GetRowCount(strFilterOn)
        if (postFilterRowCount != preFilterRowCount):
            Log.Error("Validate Filter For Condition {Where " + strFilterOn +
                      " = " + strFilterValue +
                      "} is Fail. Actual Row Count {" +
                      str(postFilterRowCount) + "} Expected Value: {" +
                      str(preFilterRowCount) + "}")
        else:
            Logger.CheckPoint("Validate Filter For Condition {Where " +
                              strFilterOn + " = " + strFilterValue +
                              "} is Pass. Actual Row Count {" +
                              str(postFilterRowCount) + "} Expected Value: {" +
                              str(preFilterRowCount) + "}")
    else:
        WebObjSearch = Users.Search()
        WebObjSearch.Click()
        VerifyFilter(strFilterOn, strFilterValue)