namespace WatirRecorder { public class WatirMaker { /// /// Sets the text field. /// /// The how. /// The name. /// The val. /// public string SetTextField(string how, string name, string val) { string setvalue = string.Format("ie.text_field({0}, '{1}').set('{2}')",how,name,val.Replace("'",@"\'")); return setvalue; } /// /// Checks the Checkboxe /// /// The how. /// The name. /// The val. /// public string Checkbox(string how, string name, string val) { string setvalue = null; if (val == "on") setvalue = string.Format("ie.checkbox({0}, '{1}').set()",how,name); else setvalue = string.Format("ie.checkbox({0}, '{1}').clear()",how,name); return setvalue; } /// /// Checks a radiobutton /// /// The how. /// The name. /// The val. /// public string Radio(string how, string name, string val) { string setvalue = null; setvalue = string.Format("ie.radio({0}, '{1}','{2}').set()",how,name,val.Replace("'",@"\'")); return setvalue; } /// /// Selects the list. /// /// The how. /// The name. /// The val. /// public string SelectList(string how, string name, string val) { string setvalue = null; setvalue = string.Format("ie.select_list({0}, '{1}').select_value('{2}')",how,name,val.Replace("'",@"\'")); return setvalue; } /// /// Clicks the link. /// /// The how. /// The name. /// public string ClickLink(string how, string name) { string setvalue = string.Format("ie.link({0}, '{1}').click",how,name.Replace("\r\n", "")); return setvalue; } /// /// Clicks the button. /// /// The how. /// The name. /// The val. /// public string ClickButton(string how, string name, string val) { string setvalue = null; if (name != null) { setvalue = string.Format("ie.button({0}, '{1}').click",how,name); } else if (val != null) { setvalue = string.Format("ie.button(:value, '{0}').click",val.Replace("'",@"\'")); } return setvalue; } /// /// Clicks assertion button /// /// The markup expected to exist. /// public string AssertExists(string assert) { string setvalue = null; assert = assert.Replace("\"", "\\\""); setvalue = string.Format("assert(ie.contains_text(\"{0}\"))", assert); return setvalue; } } }