Ejemplo n.º 1
0
        private void NumericType_CheckedChanged(object sender, EventArgs e)
        {
            string _method = (sender as RadioButton).Name;

            string strNumericType = "as int";

            if (txtTestValue.Text.Contains("."))
            {
                strNumericType = "as decimal";
            }

            string strElement = wscript.DetermineFindMethod(browsername, currentelement) + ".HTMLElement.getAttributeValue(\"" + txtAttribute.Text + "\") " + strNumericType;

            _method = "Assert." + _method.Remove(0, 2) + "(" + txtTestValue.Text + ", (" + strElement + "), \"" + txtMessage.Text + "\");";
            wscript.AddScriptLine(_method);
            this.Close();
        }
Ejemplo n.º 2
0
        private void cEXWB1_BeforeNavigate2(object sender, csExWB.BeforeNavigate2EventArgs e)
        {
            if (e.postdata == null)
            {
                e.Cancel = true;
                return;
            }

            // get the using statements and code
            byte[] byteData    = e.postdata as byte[];
            string strPostData = System.Text.ASCIIEncoding.ASCII.GetString(byteData);

            strPostData = strPostData.Remove(strPostData.Length - 1);
            strPostData = strPostData.Replace("+", " ");

            string[]            arrPostData = strPostData.Split("&".ToCharArray());
            NameValueCollection nvcPost     = new NameValueCollection();

            for (int i = 0; i < arrPostData.Length; i++)
            {
                string[] pair  = arrPostData[i].Split("=".ToCharArray());
                string   value = System.Uri.UnescapeDataString(pair[1]);
                nvcPost.Add(pair[0], value);
            }

            /*
             * // add using statements
             * string[] usings = nvcPost.GetValues("Using");
             * if (usings != null)
             * {
             *  for (int i = 0; i < usings.Length; i++)
             *  {
             *      wscript.FunctionUsing.Add(usings[i]);
             *  }
             * }
             */

            // find function page to know what assemblies to add
            string[] arrfunctionnames = nvcPost.GetValues("FunctionTitle");
            if (arrfunctionnames != null)
            {
                FunctionPage page = wscript.fcnManager.GetPageFromTitle(arrfunctionnames[0]);
                if (page != null)
                {
                    for (int i = 0; i < page.scAssemblies.Count; i++)
                    {
                        wscript.FunctionAssemblies.Add(page.scAssemblies[i]);
                    }
                }
            }

            // add code, replacing %variable% with the find method
            string varprefix = wscript.DetermineFindMethod(browsername, currentelement, lbAttributes.CheckedItems);

            if (varprefix == "")
            {
                varprefix = wscript.DetermineFindMethod(browsername, currentelement);
                if (varprefix == "")
                {
                    varprefix = Properties.Resources.UnknownItem;
                }
            }

            string[] code = nvcPost.GetValues("Code");
            if (code != null)
            {
                for (int i = 0; i < code.Length; i++)
                {
                    wscript.AddScriptLine(code[i].Replace("%variable%", varprefix));
                }
            }

            this.Close();

            e.Cancel = true;
        }