private void PopulateCriteriaByType(SearchCriteria criteria, string fieldValue) { string fieldType = criteria.GetString(true); if (fieldType.Equals(TEXT)) { if (criteria.Equals(SearchCriteria.MSLNo)) { EnterCriteria_MSLNumber(fieldValue); } else if (criteria.Equals(SearchCriteria.DocumentType)) { SelectDDL_DocumentType(fieldValue); EnterCriteria_Number(fieldValue); } else { PageAction.EnterText(By.Id(criteria.GetString()), fieldValue); } } else if (fieldType.Equals(DATE)) { EnterDate_From(GetPastShortDate(fieldValue)); EnterDate_To(fieldValue); } else if (fieldType.Equals(DDL) || fieldType.Equals(MULTIDDL)) { if (criteria.Equals(SearchCriteria.DocumentType)) { fieldValue = $"-- {fieldValue}"; } bool isMultiselectDDList = false; if (fieldType.Equals(MULTIDDL)) { isMultiselectDDList = true; } PageAction.ExpandAndSelectFromDDList(criteria, fieldValue, true, isMultiselectDDList); } }
private KeyValuePair <EntryFieldType, string> PopulateFieldValue <T>(EntryFieldType entryField, T indexOrText, bool useContains = false) { string fieldType = entryField.GetString(true); Type argType = indexOrText.GetType(); object argValue = null; bool isValidArg = false; KeyValuePair <EntryFieldType, string> fieldValuePair; string fieldValue = string.Empty; try { if (argType == typeof(string)) { isValidArg = true; argValue = ConvertToType <string>(indexOrText); } else if (argType == typeof(int)) { isValidArg = true; argValue = ConvertToType <int>(indexOrText); } if (isValidArg) { switch (fieldType) { case TEXT: case DATE: case FUTUREDATE: if (!((string)argValue).HasValue()) { if (fieldType.Equals(DATE) || fieldType.Equals(FUTUREDATE)) { argValue = fieldType.Equals(DATE) ? GetShortDate() : GetFutureShortDate(); } else { //argValue = GetVarForEntryField(entryField); argValue = GetVar(entryField); int argValueLength = ((string)argValue).Length; By inputLocator = GetInputFieldByLocator(entryField); int elemMaxLength = int.Parse(PageAction.GetAttribute(inputLocator, "maxlength")); argValue = argValueLength > elemMaxLength ? ((string)argValue).Substring(0, elemMaxLength) : argValue; } fieldValue = (string)argValue; } PageAction.EnterText(By.Id(entryField.GetString()), fieldValue); break; case DDL: case MULTIDDL: if ((argType == typeof(string) && !((string)argValue).HasValue()) || (int)argValue < 1) { argValue = 1; } bool isMultiselectDDList = false; if (fieldType.Equals(MULTIDDL)) { isMultiselectDDList = true; } PageAction.ExpandAndSelectFromDDList(entryField, argValue, useContains, isMultiselectDDList); break; case RDOBTN: case CHKBOX: PageAction.SelectRadioBtnOrChkbox(entryField); break; case UPLOAD: PageAction.UploadFile(); break; default: break; } } else { log.Error($"Argument type ({argType}) is not supported : {indexOrText.ToString()}"); } } catch (Exception e) { log.Error(e.StackTrace); } return(fieldValuePair = new KeyValuePair <EntryFieldType, string>(entryField, fieldValue)); }
public override void EnterCriteria_MSLNumber(string text) => PageAction.EnterText(GetTextInputFieldByLocator(SearchCriteria.MSLNo), text);
public virtual void EnterText_OriginatorDocumentRef(string text) => PageAction.EnterText(GetTextInputFieldByLocator(SearchCriteria.OriginatorDocumentRef), text);
//For I15SB, SH249, SG public virtual void EnterCriteria_MSLNumber(string text) => PageAction.EnterText(GetTextInputFieldByLocator(SearchCriteria.Owner_MSLNumber), text);
//Not used in tenant(s): GLX & LAX public virtual void EnterCriteria_Number(string text) => PageAction.EnterText(GetTextInputFieldByLocator(SearchCriteria.Number), $"{text.ReplaceSpacesWithUnderscores()}0000");
public virtual void EnterText_Attention(string text) => PageAction.EnterText(GetTextInputFieldByLocator(SearchCriteria.Attention), text);
public virtual void EnterText_TransmittalNumber(string text) => PageAction.EnterText(GetTextInputFieldByLocator(SearchCriteria.TransmittalNumber), text);
public virtual void EnterText_Title(string text) => PageAction.EnterText(GetTextInputFieldByLocator(SearchCriteria.Title), text);
public override void EnterDate_To(string toDate) => PageAction.EnterText(GetTextInputFieldByLocator(SearchCriteria.TransmittalDate_To), toDate);
public override void EnterDate_From(string fromDate) => PageAction.EnterText(GetTextInputFieldByLocator(SearchCriteria.TransmittalDate_From), fromDate);