Validate input is (null) or ""
Posted: Fri Sep 16, 2016 11:44 pm
I have looked at many old posts regarding null values and dealing with them in different ways. none of them have helped me.
One of the inputs I have has a value field, the other doesn't, so I am getting null for one and "" for the other. I want to: (I don't want to have failures in my test cases.)
How can I do this?
This is my current code:
James
One of the inputs I have has a value field, the other doesn't, so I am getting null for one and "" for the other. I want to: (I don't want to have failures in my test cases.)
- validate that the value is null
validate that the value is an empty string.
How can I do this?
This is my current code:
public void ValidateTextboxAndText(Ranorex.Adapter repoItem, String text, Boolean disabled = false) { if (text == "") { if (repoItem.Element.GetAttributeValueText("Text") == null) { Validate.Attribute(repoItem, "Value", ((string)null), "Validating AttributeEqual (Text='(null)') Failure of this is ok", false); } else { Validate.Attribute(repoItem, "Value", "", "Validating AttributeEqual (Text='') Failure of this is ok", false); } } else { Validate.Attribute(repoItem, "Value", text); } Validate.Attribute(repoItem, "Disabled", disabled.ToString()); Validate.Attribute(repoItem, "Hidden", "False"); Validate.Attribute(repoItem, "readonly", BoolToReadOnly(disabled)); }Thanks,
James