Example #1
0
        /// <summary>
        /// Adds a selectlist action to the action list
        /// </summary>
        /// <param name="windowName">window where it was performed</param>
        /// <param name="activeElement">element the click was performed on</param>
        /// <param name="url">current url for action</param>
        /// <returns>action created (mainly for testing)</returns>
        public ActionSelect AddSelect(string windowName, IHTMLSelectElement activeElement, string url)
        {
            var action = new ActionSelect(_browsers[windowName], (IHTMLElement)activeElement, url);

            AddAction(action);
            return(action);
        }
Example #2
0
        public String GetSelectValueById(String id)
        {
            IHTMLSelectElement element = (IHTMLSelectElement)GetElementById(id);
            IHTMLOptionElement option  = element.options[element.selectedIndex];

            return(option.value);
        }
Example #3
0
 protected bool FillSelectElement(IHTMLSelectElement element, FillParameter parameter, string value)
 {
     if (parameter.CanContain && value != null)
     {
         for (int i = 0; i < element.length; i++)
         {
             IHTMLOptionElement option = element.item(i);
             if (option.text != null && option.text.Contains(value))
             {
                 //element.selectedIndex = i;
                 element.options[i].selected = true;
                 this.InvokeOnChange(element as IHTMLElement);
                 return(true);
             }
         }
     }
     else
     {
         for (int i = 0; i < element.length; i++)
         {
             IHTMLOptionElement option = element.item(i);
             if (option.text == value)
             {
                 //element.selectedIndex = i;
                 element.options[i].selected = true;
                 this.InvokeOnChange(element as IHTMLElement);
                 return(true);
             }
         }
     }
     return(false);
 }
        private IHTMLSelectElement QuerySelectInterface()
        {
            Debug.Assert(null != m_ihostedElement);
            IHTMLSelectElement iSelect = (IHTMLSelectElement)m_ihostedElement.DomElement;

            if (null == iSelect)
            {
                return(null);
            }

            return(iSelect);
        }
Example #5
0
        static void DispatchChangeEvent(WebControl awc, int iIndex, string sControl, IHTMLSelectElement ihie, IHTMLOptionElement ihoe, IHTMLDocument2 oDoc2)
        {
            ihoe.selected = true;
            object dummy = null;
            IHTMLDocument4 oDoc4 = (IHTMLDocument4)oDoc2;
            object eventObj = oDoc4.CreateEventObject(ref dummy);
            IHTMLEventObj2 obj2 = (IHTMLEventObj2)eventObj;

            IHTMLSelectElement hsec = ihie as IHTMLSelectElement;
            awc.ReportNavState("Before FireEvent");
            hsec.FireEvent("onchange", ref eventObj);
            awc.ReportNavState("After FireEvent");
        }
Example #6
0
        private void DoSelectChange(object sender, IHTMLEventObj evt)
        {
            IHTMLElement element = evt.srcElement;
            string       locator = LocateDetector.Detect(element);

            IHTMLSelectElement select = element as IHTMLSelectElement;
            IHTMLOptionElement option = IE.Element.GetOption(select, string.Format("index={0}", select.selectedIndex));

            if (null == option)
            {
                return;
            }

            this.OnCommandRecording("select", locator, "label=" + option.text);
        }
        private static void recordSelectEvent(IHTMLElement element)
        {
            IHTMLSelectElement selectelement = element as IHTMLSelectElement;
            IHTMLElement       selement      = selectelement.item(selectelement.selectedIndex) as IHTMLElement;
            String             value         = selement.innerText;

            if (!String.IsNullOrEmpty(value))
            {
                CognizantITS.sendRecordedObject(element, "selectByVisibleText", "@" + value);
            }
            else
            {
                CognizantITS.sendRecordedObject(element, "selectByIndex", "@" + selectelement.selectedIndex);
            }
        }
Example #8
0
        public static bool IsSelectElement(SUIHtmlControlBase ctrl)
        {
            bool itis = false;

            try
            {
                IHTMLSelectElement select = ctrl.HtmlElement as IHTMLSelectElement;
                int size = select.size;
                itis = true;
            }
            catch
            {
                itis = false;
            }
            return(itis);
        }
Example #9
0
        private static void FillSelect(IHTMLSelectElement element, string value, string converted, bool fireOnchange)
        {
            if (null == element)
            {
                return;
            }

            bool   selected = false;
            string oldValue = null == element.value ? "" : element.value;

            // 首先根据文本匹配
            foreach (IHTMLOptionElement option in element.options)
            {
                if (option.text.Equals(value))
                {
                    option.selected = true;
                    selected        = true;
                }
            }

            // 然后根据转换后值进行文本匹配
            if (!selected && null != converted)
            {
                foreach (IHTMLOptionElement option in element.options)
                {
                    if (option.text.Equals(converted))
                    {
                        option.selected = true;
                        selected        = true;
                    }
                }

                // 最后根据转换后的值匹配
                if (!selected)
                {
                    element.value = converted;
                }
            }

            string newValue = null == element.value ? "" : element.value;

            if (!oldValue.Equals(newValue) && fireOnchange)
            {
                ((IHTMLElement3)element).FireEvent("onchange");
            }
        }
Example #10
0
        static void DispatchChangeEventTry2(
            WebControl awc,
            int iIndex,
            string sControl,
            IHTMLSelectElement ihie,
            IHTMLOptionElement ihoe,
            IHTMLDocument2 oDoc2)
        {
            object dummy = null;
            IHTMLDocument4 oDoc4 = (IHTMLDocument4) oDoc2;
            object eventObj = oDoc4.CreateEventObject(ref dummy);
            IHTMLEventObj2 obj2 = (IHTMLEventObj2) eventObj;

            IHTMLElement3 ihe3 = (IHTMLElement3) ihie;
            awc.ResetNav();
            awc.ReportNavState("Before FireEvent");
//            ihe3.FireEvent("onchange", ref eventObj);

            HtmlElement head = awc.AxWeb.Document.GetElementsByTagName("head")[0];
            HtmlElement scriptEl = awc.AxWeb.Document.CreateElement("script");
            IHTMLScriptElement element = (IHTMLScriptElement) scriptEl.DomElement;

            // element.text = $"function changeSelect() {{ $'({sControl}').trigger('change'); }}";
            element.text = "function triggerOnChange() "
                           + "{{ "
                           +
//                           "alert('im here'); " +
                           $"var ctl = document.getElementById('{sControl}'); "
                           +
//                           "alert(ctl); "+
                           "var evt = document.createEvent('HTMLEvents'); "
                           + "evt.initEvent('change', false, true); "
                           + "ctl.dispatchEvent(evt);"
                           + "}} ";
            // element.text = $"function triggerOnChange() {{ alert('{sControl}');}}";
            head.AppendChild(scriptEl);

            // ArbWeb.AwMainForm.DebugModelessWait();
            awc.AxWeb.Document.InvokeScript("triggerOnChange");
            // ArbWeb.AwMainForm.DebugModelessWait();
            awc.ReportNavState("After FireEvent");
            awc.WaitForBrowserReady();
            awc.WaitDoLog(500);
        }
Example #11
0
        public static RecEventArgs CreateRecEvent(IHTMLElement htmlElem, IBrowser twbstBrowser)
        {
            htmlElem = FilterHtmlElement(htmlElem);

            RecEventArgs result = new RecEventArgs();
            String       topURL = twbstBrowser.url;

            result.htmlTargetElem = htmlElem;
            result.browser        = twbstBrowser;
            result.tagName        = htmlElem.tagName.ToLower();
            result.browserURL     = topURL;
            result.browserTitle   = twbstBrowser.title;
            result.browserAppName = twbstBrowser.app;
            result.browserHwnd    = 0; /*twbstBrowser.nativeBrowser.HWND;*/ // TODO: gotta solve exception? Maybe we don't need the handle after all...
            result.BuildAttributeDictionary(htmlElem);
            result.BuildValuesList(htmlElem);

            IHTMLInputElement inputElem = htmlElem as IHTMLInputElement;

            if (inputElem != null)
            {
                result.inputType = inputElem.type.ToLower();

                if ((result.inputType == "checkbox") || (result.inputType == "radio"))
                {
                    result.isChecked = inputElem.@checked;
                }
            }

            IHTMLSelectElement selectElem = htmlElem as IHTMLSelectElement;

            if (selectElem != null)
            {
                result.isMultipleSelection = selectElem.multiple;
            }

            return(result);
        }
Example #12
0
        public void option_set_selected()
        {
            var window = CQ.Create();

            IHTMLSelectElement select = (IHTMLSelectElement)window.Document.CreateElement("select");

            var option0 = window.Document.CreateElement("option");

            select.AppendChild(option0);
            option0.SetAttribute("selected", "selected");

            var optgroup = window.Document.CreateElement("optgroup");

            select.AppendChild(optgroup);
            var option1 = window.Document.CreateElement("option");

            optgroup.AppendChild(option1);

            Assert.AreEqual(true, option0.Selected, "initially selected");
            Assert.AreEqual(false, option1.Selected, "initially not selected");
            Assert.AreEqual(option1, select.Options[1], "options should include options inside optgroup");

            //option1.DefaultSelected = true;
            option1.Selected = true;

            Assert.AreEqual(false, option0.Selected, "selecting other option should deselect this");
            //Assert.AreEqual(true, option0.defaultSelected, "default should not change");
            Assert.AreEqual(true, option1.Selected, "selected changes when defaultSelected changes");
            //Assert.AreEqual(true, option1.defaultSelected, "I just set this");

            //option0.defaultSelected = false;
            option0.Selected = true;
            Assert.AreEqual(true, option0.Selected, "I just set this");
            //Assert.AreEqual(false, option0.defaultSelected, "selected does not set default");
            Assert.AreEqual(false, option1.Selected, "should deselect others");
            //Assert.AreEqual(true, option1.defaultSelected, "unchanged");
        }
        protected override bool ReadyToPaste(PaymentRequest request)
        {
            HTMLDocument doc = request.Document;
            IEnumerator  e   = doc.getElementsByTagName("div").GetEnumerator();

            while (e.MoveNext())
            {
                if (TrimHtml((e.Current as IHTMLElement).innerHTML).ToLower().StartsWith(DOMESTIC_TRANSFER_TEXT))
                {
                    IHTMLSelectElement beneficiaryList = doc.getElementById(BENEFICIARY_LIST) as IHTMLSelectElement;
                    if (beneficiaryList == null || doc.getElementsByName(DAY_FIELD).length == 0)
                    {
                        return(false);
                    }
                    else if (request.PaymentInfo.IsDefinedTransfer == false)
                    {
                        return(beneficiaryList.selectedIndex == 0);
                    }
                    else
                    {
                        String text = TrimHtml((beneficiaryList.item(beneficiaryList.selectedIndex, null) as IHTMLOptionElement).text).ToLower();
                        if (text.EndsWith(TRUSTED_POSTFIX))
                        {
                            text = text.Substring(0, text.IndexOf(TRUSTED_POSTFIX));
                        }
                        else if (text.EndsWith(NORMAL_POSTFIX))
                        {
                            text = text.Substring(0, text.IndexOf(NORMAL_POSTFIX));
                        }
                        return(request.PaymentInfo.DefinedTransferName.ToLower().Equals(text));
                    }
                }
            }

            return(false);
        }
Example #14
0
        static void DispatchEventNew(ArbWebControl awc, int iIndex, string sControl, IHTMLSelectElement ihie, IHTMLOptionElement ihoe, IHTMLDocument2 oDoc2)
        {
            ihoe.selected = true;
            object dummy = null;
            IHTMLDocument4 oDoc4 = awc.Document4;
            object eventObj = oDoc4.CreateEventObject(ref dummy);
            var obj = eventObj;
            obj.initEvent("onchange", true, true);

            IHTMLEventObj2 obj2 = (IHTMLEventObj2)eventObj;

            HTMLSelectElementClass hsec = ihie as HTMLSelectElementClass;
            awc.ReportNavState("Before FireEvent");
            hsec.selectedIndex = iIndex;
            
            obj2.fromElement = hsec;
            obj2.srcElement = hsec;
            obj2.propertyName = sControl;

            bool f;
            oDoc4.FireEvent("change", ref eventObj);

            awc.ReportNavState("After FireEvent");
        }
Example #15
0
 public SUIHtmlSelect(SUIHtmlDocument _doc, IHTMLElement _element)
     : base(_doc, _element)
 {
     selectElement = (IHTMLSelectElement)_element;
 }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Select"/> class.
 /// </summary>
 /// <param name="ae"></param>
 public Select(IHTMLElement ihe)
     : base(ihe)
 {
     this.ihse = (IHTMLSelectElement)ihe;
     this.hse = (HTMLSelectElement)ihe;
 }
Example #17
0
        //private void FillElement(FillParameterKey parameterKey, object elementContainer, String parameterValue)
        //{
        //    this.Wait();
        //    FillParameter fillParameter = elementContainer as FillParameter;
        //    if (fillParameter == null)
        //    {
        //        Hashtable table = elementContainer as Hashtable;
        //        if (table == null)
        //            return;
        //        else if (parameterKey.Type == Matcher.TYPE_RADIO)
        //        {
        //            // 处理radio类型的选择
        //            if (parameterValue != null)
        //                fillParameter = table[parameterValue] as FillParameter;
        //        }
        //        else if (parameterKey.Type == Matcher.TYPE_CHECKBOX) // 处理checkBox类型
        //        {
        //            FillCheckBoxGroup(ref parameterValue, table);
        //            return;
        //        }
        //    }
        //    FillElement(fillParameter, ref parameterValue);
        //}

        //下拉框填报:1.如果只有一个选项就选中  2.如果选项有其他而且值没有其他符合项就选中其他
        private bool FillSelectElement(FillParameter parameter, ref string value)
        {
            IHTMLSelectElement element = base.GetElement(parameter, _formIndex) as IHTMLSelectElement;

            if (element == null)
            {
                return(false);
            }
            List <IHTMLOptionElement> listOptions = new List <IHTMLOptionElement>();
            IHTMLOptionElement        otherOption = null;

            //分割参数值,已经填充的参数值从中删掉
            string[] values = value == null ? null : value.Split(PZHFillManager.regularSeparator, StringSplitOptions.RemoveEmptyEntries);
            if (values == null || values.Length < 1)
            {
                return(false);
            }
            List <String> listValues = new List <String>(values);

            for (int i = 0; i < element.length; i++)
            {
                IHTMLOptionElement option = element.item(i);
                if (String.IsNullOrWhiteSpace(option.text))
                {
                    continue;
                }
                listOptions.Add(option);
                if (option.text == "其他")
                {
                    otherOption = option;
                }
                if (parameter.CanContain)
                {
                    String selectedItem = null;
                    foreach (String item in listValues)
                    {
                        if (option.text.Contains(item))
                        {
                            option.selected = true;
                            selectedItem    = item;
                            break;
                        }
                    }
                    if (parameter.CanDelete && !String.IsNullOrEmpty(selectedItem))
                    {
                        listValues.Remove(selectedItem);
                    }
                }
                else
                {
                    if (listValues.Contains(option.text))
                    {
                        option.selected = true;
                        if (parameter.CanDelete)
                        {
                            listValues.Remove(option.text);
                        }
                        value = String.Join(PZHFillManager.regularJoiner, listValues);
                        base.InvokeChange2(element as IHTMLElement);
                        return(true);
                    }
                }
            }
            if (listOptions.Count == 1)
            {
                listOptions[0].selected = true;
                base.InvokeChange2(element as IHTMLElement);
                return(true);
            }
            foreach (IHTMLOptionElement option in listOptions)
            {
                if (option.text == "其他")
                {
                    option.selected = true;
                    base.InvokeChange2(element as IHTMLElement);
                    return(true);
                }
            }
            return(false);
        }
Example #18
0
 public SUIHtmlSelect(SUIHtmlDocument _doc, IHTMLElement _element)
     : base(_doc, _element)
 {
     selectElement = (IHTMLSelectElement)_element;
 }
Example #19
0
 public SUIHtmlSelect(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     selectElement = (IHTMLSelectElement)ctrl.HtmlElement;
 }
Example #20
0
        public static void FillSelect(HTMLDocument document, string id, string value, string converted, bool fireOnchange = false)
        {
            IHTMLSelectElement element = (IHTMLSelectElement)document.getElementById(id);

            FillSelect(element, value, converted, fireOnchange);
        }
Example #21
0
 public SelectElement(IHTMLSelectElement e, DocumentElement d)
     : base(e as IHTMLElement, d)
 {
 }
        /// <summary>
        /// Returns the <see cref="NameValueType" /> instances corresponding to the selected option elements that are contained in
        /// the provided select element.
        /// </summary>
        /// <param name="select">The select element to inspect.</param>
        /// <returns>A sequence of <see cref="NameValueType" /> instances for each selected option.</returns>
        private static IEnumerable<NameValueType> GetOptionKeyValueTuples(IHTMLSelectElement select)
        {
            IEnumerable<IDomElement> optionNodes = select
                .ChildElements
                .Concat(select
                    .ChildElements
                    .Where(e => e.NodeName == "OPTGROUP")
                    .SelectMany(e => e.ChildElements))
                .Where(e => e is IHTMLOptionElement);

            foreach (IDomElement option in optionNodes)
            {
                if (option.Selected && !option.Disabled)
                {
                    string value;
                    if (option.HasAttribute("value"))
                    {
                        value = option.GetAttribute("value", string.Empty);
                    }
                    else
                    {
                        value = StripAndCollapseWhitespace(WebUtility.HtmlDecode(option.InnerText));
                    }
                    yield return new NameValueType(select.Name, value, select.Type);
                }
            }
        }
        public override bool SetPropertyValue(string argProperty, object argValue)
        {
            if (string.Equals(argProperty, UIPropertyKey.s_selectIndexKey, StringComparison.OrdinalIgnoreCase))
            {
                if (null == argValue ||
                    !(argValue is int))
                {
                    return(false);
                }

                try
                {
                    IHTMLSelectElement iSelect = QuerySelectInterface();
                    iSelect.selectedIndex = (int)argValue;
                    iSelect = null;
                }
                catch (System.Exception ex)
                {
                    Log.UIService.LogWarn("Failed to set property value of a select element", ex);
                    return(false);
                }

                return(true);
            }
            else if (string.Equals(argProperty, UIPropertyKey.s_selectTitleKey, StringComparison.OrdinalIgnoreCase))
            {
                if (null == argValue ||
                    !(argValue is string))
                {
                    return(false);
                }
                try
                {
                    IHTMLSelectElement iSelect = QuerySelectInterface();
                    string             Title   = (string)argValue;
                    int index = 0;
                    foreach (IHTMLOptionElement option in iSelect.options)
                    {
                        if (string.Equals(option.text, Title, StringComparison.Ordinal))
                        {
                            iSelect.selectedIndex = index;
                            break;
                        }
                        ++index;
                    }
                    iSelect = null;
                }
                catch (System.Exception ex)
                {
                    Log.UIService.LogWarn("Failed to set property value of a select element", ex);
                    return(false);
                }

                return(true);
            }
            else if (string.Equals(argProperty, UIPropertyKey.s_selectValueKey, StringComparison.OrdinalIgnoreCase))
            {
                if (null == argValue ||
                    !(argValue is string))
                {
                    return(false);
                }
                try
                {
                    IHTMLSelectElement iSelect = QuerySelectInterface();
                    string             opValue = (string)argValue;
                    int index = 0;
                    foreach (IHTMLOptionElement option in iSelect.options)
                    {
                        if (string.Equals(option.value, opValue, StringComparison.Ordinal))
                        {
                            iSelect.selectedIndex = index;
                            break;
                        }
                        ++index;
                    }
                    iSelect = null;
                }
                catch (System.Exception ex)
                {
                    Log.UIService.LogWarn("Failed to set property value of a select element", ex);
                    return(false);
                }

                return(true);
            }
            else if (string.Equals(argProperty, UIPropertyKey.s_ItemSourceKey, StringComparison.OrdinalIgnoreCase))
            {
                if (null == argValue ||
                    !(argValue is UISelectOptionsCollection))
                {
                    return(false);
                }

                try
                {
                    UISelectOptionsCollection options = (UISelectOptionsCollection)argValue;
                    HtmlElement element = null;
                    foreach (var item in options.Options)
                    {
                        element = m_ihostedElement.Document.CreateElement("Option");
                        if (null != element)
                        {
                            element.InnerText = item.Title;
                            if (!string.IsNullOrEmpty(item.Value))
                            {
                                element.SetAttribute("value", item.Value);
                            }

                            m_ihostedElement.AppendChild(element);
                        }
                    }
                }
                catch (Exception exp)
                {
                    Trace.Write(exp.Message);
                    return(false);
                }

                return(true);
            }
            else
            {
                return(base.SetPropertyValue(argProperty, argValue));
            }
        }
Example #24
0
        //填充参数
        protected virtual void FillElement(FillParameter parameter, string value)
        {
            if (parameter == null)
            {
                return;
            }
            IHTMLElement element = null;

            if (parameter.Type != Matcher.TYPE_FORM)
            {
                //查找元素,如果是null就是代表没有此元素
                element = GetElement(parameter, GetFormIndex(parameter));
                if (element == null)
                {
                    this.FillRecords.Add(new FillRecord(GetElementType(parameter.Type), RecordType.Failed, "未找到此元素", parameter.ParameterName));
                    return;
                }
                if (parameter.Type == Matcher.TYPE_FILE)
                {
                    if (string.IsNullOrEmpty(value))
                    {
                        return;
                    }
                    value = File.Exists(value) ? value : (string.IsNullOrEmpty(DataFilePath) ? value : string.Format("{0}\\{1}", DataFilePath, value));
                    if (System.IO.File.Exists(value) == false)
                    {
                        this.FillRecords.Add(new FillRecord(ElementType.File, RecordType.Failed, string.Format("文件{0}不存在", value), parameter.ParameterName));
                        return;
                    }
                }
                ((IHTMLElement2)element).focus();
            }
            if (string.IsNullOrEmpty(parameter.SplitExpr) == false && string.IsNullOrEmpty(value) == false)
            {
                Match match = Regex.Match(value, parameter.SplitExpr, RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    value = match.Groups["value"].Value;
                }
            }
            _currentFillValue = value;
            switch (parameter.Type)
            {
            case Matcher.TYPE_FORM:
                UpdateFormIndex(parameter);
                break;

            case Matcher.TYPE_RADIO:
                IHTMLInputElement radioElement = element as IHTMLInputElement;
                radioElement.@checked = true;
                this.FillRecords[(int)ElementType.Radio].RecordCount++;
                break;

            case Matcher.TYPE_SELECT:
                IHTMLSelectElement selectElement = element as IHTMLSelectElement;
                if (FillSelectElement(selectElement, parameter, value))
                {
                    this.FillRecords[(int)ElementType.Select].RecordCount++;
                }
                else
                {
                    this.FillRecords.Add(new FillRecord(ElementType.Select, RecordType.Failed, string.Format("下拉框中不包含选项 {0}", value), parameter.ParameterName));
                }
                break;

            case Matcher.TYPE_A:
                element.click();
                break;

            case Matcher.TYPE_FILE:
                element.click();
                this.FillRecords[(int)ElementType.File].RecordCount++;
                break;

            case Matcher.TYPE_SUBMIT:
            case Matcher.TYPE_BUTTON:
            case "BUTTON/SUBMIT":
                IHTMLInputElement fileElement = element as IHTMLInputElement;
                element.click();
                break;

            case Matcher.TYPE_TEXTAREA:
            case Matcher.TYPE_TEXT:
            case Matcher.TYPE_PASSWORD:
                FillTextElement(element, value);
                break;
            }
        }
        public override bool GetPropertyValue(string argProperty, out object argValue)
        {
            argValue = null;
            if (string.Equals(argProperty, UIPropertyKey.s_selectIndexKey, StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    IHTMLSelectElement iSelect = QuerySelectInterface();
                    argValue = iSelect.selectedIndex;
                    iSelect  = null;
                }
                catch (System.Exception ex)
                {
                    Log.UIService.LogWarn("Failed to set property value of a select element", ex);
                    return(false);
                }

                return(true);
            }
            else if (string.Equals(argProperty, UIPropertyKey.s_selectTitleKey, StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    IHTMLSelectElement iSelect = QuerySelectInterface();
                    IHTMLOptionElement option  = iSelect.options[iSelect.selectedIndex];
                    if (null == option)
                    {
                        iSelect = null;
                        return(false);
                    }

                    argValue = option.text;
                    option   = null;
                    iSelect  = null;
                }
                catch (System.Exception ex)
                {
                    Log.UIService.LogWarn("Failed to set property value of a select element", ex);
                    return(false);
                }

                return(true);
            }
            else if (string.Equals(argProperty, UIPropertyKey.s_selectValueKey, StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    IHTMLSelectElement iSelect = QuerySelectInterface();
                    IHTMLOptionElement option  = iSelect.options[iSelect.selectedIndex];
                    if (null == option)
                    {
                        iSelect = null;
                        return(false);
                    }

                    argValue = option.value;
                    option   = null;
                    iSelect  = null;
                }
                catch (System.Exception ex)
                {
                    Log.UIService.LogWarn("Failed to set property value of a select element", ex);
                    return(false);
                }

                return(true);
            }
            else
            {
                return(base.GetPropertyValue(argProperty, out argValue));
            }
        }
        /// <summary>
        /// Checks if any defined transfer is selected on the transfer page.
        /// </summary>
        /// <param name="doc">HTML document</param>
        /// <returns>true if any defined transfer is selected or false otherwise</returns>
        private bool IsAnyTransferSelected(HTMLDocument doc)
        {
            IHTMLSelectElement select = (doc.getElementsByName(DEFINED_TRANSFER_FIELD) as IHTMLElementCollection).item(0, null) as IHTMLSelectElement;

            return(select.selectedIndex == 0 && "wybierz".Equals(TrimHtml((select.item(0, null) as IHTMLOptionElement).text).ToLower()));
        }
Example #27
0
 public SUIHtmlSelect(SUIHtmlControlBase ctrl)
     : base(ctrl)
 {
     selectElement = (IHTMLSelectElement)ctrl.HtmlElement;
 }
Example #28
0
        private void BuildValuesList(IHTMLElement htmlElem)
        {
            String tagName = htmlElem.tagName.ToLower();

            if ("input" == tagName)
            {
                String val = ((IHTMLInputElement)htmlElem).value;
                if (String.IsNullOrEmpty(val))
                {
                    String type = ((IHTMLInputElement)htmlElem).type;
                    if ((type != null) && type.ToLower() == "file")
                    {
                        val = "insert file path here";
                    }
                    else
                    {
                        val = "insert text here";
                    }
                }

                this.values.Add(val);
            }
            else if ("select" == tagName)
            {
                IHTMLSelectElement selectElem = (IHTMLSelectElement)htmlElem;
                int    len        = selectElem.length;
                Object dummyIndex = 0;

                for (int i = 0; i < len; ++i)
                {
                    Object       crntIndex = i;
                    IHTMLElement crntElem  = (IHTMLElement)selectElem.item(crntIndex, dummyIndex);

                    IHTMLOptionElement crntOption = crntElem as IHTMLOptionElement;
                    if (crntOption != null)
                    {
                        if (crntOption.selected)
                        {
                            // I don't know why spaces appears like 0xA0 (no break space).
                            String crntOptionText = crntOption.text;
                            if (crntOptionText != null)
                            {
                                crntOptionText = crntOptionText.Replace('\xA0', '\x20');
                                this.values.Add(crntOptionText);
                            }
                            else
                            {
                                IHTMLOptionElement3 crntOption3 = crntOption as IHTMLOptionElement3;
                                if (crntOption3 != null)
                                {
                                    crntOptionText = crntOption3.label;
                                    if (crntOptionText != null)
                                    {
                                        crntOptionText = crntOptionText.Replace('\xA0', '\x20');
                                        this.values.Add(crntOptionText);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if ("textarea" == tagName)
            {
                String val = ((IHTMLInputElement)htmlElem).value;
                if (String.IsNullOrEmpty(val))
                {
                    val = "insert your text here";
                }

                this.values.Add(val);
            }
        }
Example #29
0
        private void RegCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            wb_.DocumentCompleted -= RegCompleted;

            // Input Reg Info.
            IHTMLDocument2   doc  = (IHTMLDocument2)wb_.Document.DomDocument;
            IHTMLFormElement form = doc.forms.item("main");

            IDictionary <string, string> info = GetRegInfo();

            // Account
            {
                IHTMLInputElement accEle = form.item("username");
                accEle.value = info["username"];
            }

            // Pwd
            {
                IHTMLInputElement pwdEle = form.item("password");
                pwdEle.value = info["password"];
                IHTMLInputElement pwdConfirmEle = form.item("password2");
                pwdConfirmEle.value = info["password"];
            }

            // Real Name
            {
                IHTMLInputElement aliasEle = form.item("alias");
                aliasEle.value = info["alias"];
            }

            // PwdSecurityQuestion
            {
                IHTMLSelectElement qEle = form.item("question");
                qEle.selectedIndex = int.Parse(info["question"]);
            }

            // PwdSecurityAnswer
            {
                IHTMLInputElement aEle = form.item("answer");
                aEle.value = info["answer"];
            }

            // Sex
            // Use default value.
            //{
            //    IHTMLSelectElement sexEle = form.item("answer");
            //    sexEle.selectedIndex = int.Parse(info["answer"]);
            //}

            //  CreditCard Pwd
            {
                IHTMLSelectElement aEle = form.item("drpAuthCodea");
                aEle.selectedIndex = int.Parse(info["drpAuthCodea"]);

                IHTMLSelectElement bEle = form.item("drpAuthCodeb");
                bEle.selectedIndex = int.Parse(info["drpAuthCodeb"]);

                IHTMLSelectElement cEle = form.item("drpAuthCodec");
                cEle.selectedIndex = int.Parse(info["drpAuthCodec"]);

                IHTMLSelectElement dEle = form.item("drpAuthCoded");
                dEle.selectedIndex = int.Parse(info["drpAuthCoded"]);
            }

            // BirthDay
            {
                IHTMLSelectElement yearEle = form.item("year11");
                yearEle.selectedIndex = int.Parse(info["year11"]);

                IHTMLSelectElement monthEle = form.item("maoth11");
                monthEle.selectedIndex = int.Parse(info["month11"]);

                IHTMLSelectElement dayEle = form.item("day11");
                dayEle.selectedIndex = int.Parse(info["day11"]);
            }

            // All use default.
            // Nation
            {
                IHTMLInputElement nationEle = form.item("contory");
            }

            // City
            {
                IHTMLInputElement cityEle = form.item("city");
            }
            // KnownWay
            {
                //...
            }
            // Agreement
            {
            }


            // Submit
            {
                IHTMLElement submitEle = form.item("submitBtn");
                submitEle.click();
            }
        }