I have an xml file with specific steps and actions that should be performed on html controls:
<Item control="Dropdown" action="Click" value=""/> <Item control="Button" action="GetText" value=""/> <Item control="Input" action="WriteText" value="Sample Text"/>
There are many controls that I will use, and each control has several methods, such as Click , GetText , Exsists ..
I am currently using switches to handle this, but I heard that is not a good practice. I have one switch for selecting a specific control, and also each control has a switch for calling a specific method.
switch (control) { case "button": return new Button; case "table": return new Table; (...) } (...) switch (action) { case "click": this.Click(); return true; case "gettext": this.GetText(); return true; default: return false; }
I don't have much experience with coding, so I'm not sure if this is a good way to handle this problem. Could you give me some tips on how to do this better? Maybe there are some coding patterns that might be useful here?
source share