Beispiel #1
0
 public static List <mshtml.IHTMLElement> getElementsByTagName(
     this mshtml.IHTMLElement element,
     string tagName
     )
 {
     return(((mshtml.IHTMLElement2)element).getElementsByTagName(tagName).ToList());
 }
Beispiel #2
0
 public IEElement(Browser browser, mshtml.IHTMLElement Element)
 {
     Browser    = browser;
     RawElement = Element;
     className  = Element.className;
     id         = Element.id;
     tagName    = Element.tagName.ToLower();
     if (tagName == "input")
     {
         mshtml.IHTMLInputElement inputelement = Element as mshtml.IHTMLInputElement;
         type = inputelement.type.ToLower();
     }
     try
     {
         mshtml.IHTMLUniqueName id = RawElement as mshtml.IHTMLUniqueName;
         uniqueID = id.uniqueID;
     }
     catch (Exception)
     {
     }
     IndexInParent = -1;
     if (Element.parentElement != null && !string.IsNullOrEmpty(uniqueID))
     {
         mshtml.IHTMLElementCollection children = Element.parentElement.children;
         for (int i = 0; i < children.length; i++)
         {
             mshtml.IHTMLUniqueName id = children.item(i) as mshtml.IHTMLUniqueName;
             if (id != null && id.uniqueID == uniqueID)
             {
                 IndexInParent = i; break;
             }
         }
     }
 }
Beispiel #3
0
 public static bool attachEvent(
     this mshtml.IHTMLElement element, string @event,
     DomEventHandler.Callback callback
     )
 {
     return(((mshtml.IHTMLElement2)element).attachEvent(@event, new DomEventHandler(callback)));
 }
Beispiel #4
0
        //网页加载完成,回调函数
        private void onLoadDocCompleted(object sender, NavigationEventArgs e)
        {
            if (!isFresh)       //如果刷新状态不执行任何动作
            {
                //获取文档对象
                mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2)web1.Document;

                //判断:登录状态。登录状态通过网页标题判断。
                if (doc2.title == "红警之坦克风暴 - 应用中心")
                {
                    //获取游戏框架的iframe节点
                    mshtml.IHTMLElement m_iframe = (mshtml.IHTMLElement)doc2.all.item("app_frame", 0);
                    //获取该节点的src属性。即为游戏的免登陆URL
                    game_url = (string)m_iframe.getAttribute("src");
                    //把提取到的免登陆URL写入配置文件
                    Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                    cfa.AppSettings.Settings["Game"].Value   = game_url;             //写入游戏URL
                    cfa.AppSettings.Settings["Status"].Value = "secondtime";         //写入第二次登录标记
                    cfa.Save();
                    //重新载入免登陆URL。目的:去除腾讯QQ空间的外部框架,去除广告。
                    Uri uri = new Uri(game_url);
                    web1.Navigate(uri);
                    //启动定时器,用于刷新计时
                    timer.Start();
                    //把刷新状态改为真,进入刷新状态。网页加载完成不再执行提取操作。
                    isFresh = true;
                }
            }
        }
        private void TestElementXPath(string DataQAValue, string FireBugXPath)
        {
            //Confirm FireBug provided a valid Xpath and item is found


            // Find the element by QA data tag value
            mshtml.IHTMLElement e = GetElementbyDataQA(DataQAValue);
            if (e == null)
            {
                throw new Exception("Element not found - " + DataQAValue);
            }
            // Calc the Xpath - this is what we want to test for accuracy and make sure it find the correct element
            string XPath = MBW.GetElementXPath(e);

            mshtml.IHTMLElement n2 = MBW.GetElementByXPath(XPath);
            if (n2 == null)
            {
                throw new Exception("Element not found by XPath - " + XPath);
            }
            string QA2 = n2.getAttribute("data-QA");

            if (QA2 != DataQAValue)
            {
                throw new Exception("ERROR: QA2 != DataQAValue - " + QA2);
            }

            //Validate we found the same exact element based on QA tag - Unique
            Assert.AreEqual(QA2, DataQAValue);

            // Check if we created same XPath - can be different so fail only if QA2 != DataQAValue , else warning
            //TODO: Make warning - not fail!! can be several XPath to same element
            //Assert.AreEqual(FireBugXPath, XPath);  // False alarm so removed
        }
        protected override void HandleEvent()
        {
            if (OnWebEvent == null) return;

             			_el = _doc.elementFromPoint(_nClientX, _nClientY);
             			OnWebEvent(this, new WebEventArgs(_doc, _nClientX, _nClientY));
        }
Beispiel #7
0
        // get the selected range object
        public static HtmlElement GetFirstControl(HtmlDocument document)
        {
            // define the selected range object
            HtmlSelection    selection;
            HtmlControlRange range;
            HtmlElement      control = null;

            try
            {
                // calculate the first control based on the user selection
                selection = document.selection;
                if (selection.type.Equals("control", StringComparison.OrdinalIgnoreCase))
                {
                    range = selection.createRange() as HtmlControlRange;
                    if (range.length > 0)
                    {
                        control = range.item(0);
                    }
                }
            }
            catch (Exception)
            {
                // have unknown error so set return to null
                control = null;
            }

            return(control);
        }
Beispiel #8
0
        } //GetTableElement

        /// <summary>
        /// Get selected or parent table
        /// </summary>
        /// <returns>null if not found</returns>
        public HtmlTable GetTableElement()
        {
            // define the table and row elements and obtain there values
            HtmlTable     table = null;
            HtmlTextRange range = SelectionHelper.GetTextRange(Document);


            // first see if the table element is selected
            table = SelectionHelper.GetFirstControl(Document) as HtmlTable;
            // if table not selected then parse up the selection tree
            if (table == null && range != null)
            {
                HtmlElement element = (HtmlElement)range.parentElement();
                // parse up the tree until the table element is found
                while (element != null && table == null)
                {
                    if (element is HtmlTable)
                    {
                        table = (HtmlTable)element;
                    }
                    element = (HtmlElement)element.parentElement;
                }
            }

            // return the defined table element
            return(table);
        }
Beispiel #9
0
        public mshtml.IHTMLElement[] matches(mshtml.IHTMLElement element)
        {
            int counter = 0;

            do
            {
                try
                {
                    var matchs = new List <mshtml.IHTMLElement>();
                    mshtml.IHTMLElementCollection elements = element.children;
                    foreach (mshtml.IHTMLElement elementNode in elements)
                    {
                        if (Match(elementNode))
                        {
                            matchs.Add(elementNode);
                        }
                    }
                    Log.Selector("match count: " + matchs.Count);
                    return(matchs.ToArray());
                }
                catch (Exception)
                {
                    ++counter;
                    if (counter == 2)
                    {
                        throw;
                    }
                }
            } while (counter < 2);
            return(new mshtml.IHTMLElement[] { });
        }
Beispiel #10
0
        public string GetAttribute(string attributeName)
        {
            //return underlying.GetAttribute(attributeName);
            mshtml.IHTMLElement element = (mshtml.IHTMLElement)underlying.DomElement;
            object result = element.getAttribute(attributeName);

            return(result != null?result.ToString() : null);
        }
Beispiel #11
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     mshtml.HTMLDocument document = (mshtml.HTMLDocument)webBrowser1.Document;
     mshtml.IHTMLElement textArea = document.getElementById("curDate");
     //MessageBox.Show(textArea.innerHTML, "Contenido");
     this.curValue = textArea.innerHTML;
     this.Close();
 }
Beispiel #12
0
        private void SetHtmlValues()
        {
            mshtml.HTMLDocument document  = (mshtml.HTMLDocument)webBrowser1.Document;
            mshtml.IHTMLElement textArea1 = document.getElementById("PacientName");
            mshtml.IHTMLElement textArea2 = document.getElementById("EventDuration");

            textArea1.innerHTML = nombrePaciente;
            textArea2.innerHTML = duracion.ToString();
        }
Beispiel #13
0
 private void DoClick()
 {
     if (IsFocusable())
     {
         underlying.Focus();
     }
     mshtml.IHTMLElement element = (mshtml.IHTMLElement)underlying.DomElement;
     element.click();
 }
Beispiel #14
0
        //委托函数--转到框架
        private void SelectLoginiFrame()
        {
            mshtml.IHTMLDocument2 doc      = (mshtml.IHTMLDocument2)web1.Document;
            mshtml.IHTMLElement   l_iframe = (mshtml.IHTMLElement)doc.all.item("login_frame", 0);
            string zoneurl = (string)l_iframe.getAttribute("src");
            Uri    li_uri  = new Uri(zoneurl);

            web1.Navigate(li_uri);
        }
Beispiel #15
0
        public IESelectorItem(Browser browser, mshtml.IHTMLElement element)
        {
            this.IEElement = new IEElement(browser, element);
            this.Element   = this.IEElement;

            if (this.Element == null)
            {
                throw new Exception("Error!!!");
            }
            Properties = new ObservableCollection <SelectorItemProperty>();
            if (!string.IsNullOrEmpty(element.tagName))
            {
                Properties.Add(new SelectorItemProperty("tagName", element.tagName));
            }
            if (element.tagName.ToUpper() == "INPUT")
            {
                if (!string.IsNullOrEmpty(((mshtml.IHTMLInputElement)element).type))
                {
                    Properties.Add(new SelectorItemProperty("type", ((mshtml.IHTMLInputElement)element).type));
                }
            }

            if (!string.IsNullOrEmpty(element.className))
            {
                Properties.Add(new SelectorItemProperty("className", element.className));
            }
            if (!string.IsNullOrEmpty(element.id))
            {
                Properties.Add(new SelectorItemProperty("id", element.id));
            }
            if (this.IEElement.IndexInParent > -1)
            {
                Properties.Add(new SelectorItemProperty("IndexInParent", this.IEElement.IndexInParent.ToString()));
            }


            //Enabled = (Properties.Count > 1);
            //canDisable = true;
            //Enabled = true;
            //canDisable = true;
            foreach (var p in Properties)
            {
                p.Enabled    = true;
                p.canDisable = (Properties.Count > 1);
            }
            ;
            foreach (var p in Properties)
            {
                p.PropertyChanged += (sender, e) =>
                {
                    OnPropertyChanged("Displayname");
                    OnPropertyChanged("json");
                }
            }
            ;
        }
Beispiel #16
0
        public static mshtml.IHTMLElement GetEleFromDoc(System.Drawing.Point windowPos, int hwnd, mshtml.IHTMLDocument2 document)
        {
            int hWnd = hwnd;

            ScreenToClient(hWnd, ref windowPos);
            dynamic element = document.elementFromPoint(windowPos.X, windowPos.Y);

            mshtml.IHTMLElement ele = (mshtml.IHTMLElement)element;
            return(ele);
        }
 private mshtml.IHTMLElement Body(DocumentView documentView)
 {
     mshtml.IHTMLElement body = null;
     while (body == null || body.innerHTML == null)
     {
         this.Pause();
         var document = (mshtml.IHTMLDocument2)documentView.RenderedView.Document;
         body = (mshtml.IHTMLElement)document.body;
     }
     return(body);
 }
Beispiel #18
0
        protected override void Execute(CodeActivityContext context)
        {
            string attribute_str   = Attribute.Get(context);
            string attribute_value = Value.Get(context);

            try
            {
                Int32 _timeout = TimeoutMS.Get(context);
                Thread.Sleep(_timeout);
                latch = new CountdownEvent(1);
                Thread td = new Thread(() =>
                {
                    if (Selector.Expression == null)
                    {
                        //ActiveElement处理
                    }
                    else
                    {
                        var selStr        = Selector.Get(context);
                        UiElement element = GetValueOrDefault(context, this.Element, null);
                        if (element == null && selStr != null)
                        {
                            element = UiElement.FromSelector(selStr);
                        }
                        if (element != null)
                        {
                            element.SetForeground();
                            mshtml.IHTMLDocument2 currDoc      = null;
                            SHDocVw.InternetExplorer ieBrowser = GetIEFromHWndClass.GetIEFromHWnd((int)element.WindowHandle, out currDoc);
                            mshtml.IHTMLElement currEle        = GetIEFromHWndClass.GetEleFromDoc(
                                element.GetClickablePoint(), (int)element.WindowHandle, currDoc);
                            currEle.setAttribute(attribute_str, attribute_value);
                        }
                        else
                        {
                            UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, Localize.LocalizedResources.GetString("msgNoElementFound"));
                        }
                    }
                    refreshData(latch);
                });
                td.TrySetApartmentState(ApartmentState.STA);
                td.IsBackground = true;
                td.Start();
                latch.Wait();
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "出现异常", e.Message);
                if (ContinueOnError.Get(context))
                {
                }
            }
        }
Beispiel #19
0
        private static string getNode(mshtml.IHTMLElement node)
        {
            string nodeExpr = node.tagName;

            if (nodeExpr == null)  // Eg. node = #text
            {
                return(null);
            }
            if (node.id != "" && node.id != null)
            {
                nodeExpr += "[@id='" + node.id + "']";
                // We don't really need to go back up to //HTML, since IDs are supposed
                // to be unique, so they are a good starting point.
                return("/" + nodeExpr);
            }

            // Find rank of node among its type in the parent
            int rank = 1;

            mshtml.IHTMLDOMNode nodeDom = node as mshtml.IHTMLDOMNode;
            mshtml.IHTMLDOMNode psDom   = nodeDom.previousSibling;
            mshtml.IHTMLElement ps      = psDom as mshtml.IHTMLElement;
            while (ps != null)
            {
                if (ps.tagName == node.tagName)
                {
                    rank++;
                }
                psDom = psDom.previousSibling;
                ps    = psDom as mshtml.IHTMLElement;
            }
            if (rank > 1)
            {
                nodeExpr += "[" + rank + "]";
            }
            else
            { // First node of its kind at this level. Are there any others?
                mshtml.IHTMLDOMNode nsDom = nodeDom.nextSibling;
                mshtml.IHTMLElement ns    = nsDom as mshtml.IHTMLElement;
                while (ns != null)
                {
                    if (ns.tagName == node.tagName)
                    { // Yes, mark it as being the first one
                        nodeExpr += "[1]";
                        break;
                    }
                    nsDom = nsDom.nextSibling;
                    ns    = nsDom as mshtml.IHTMLElement;
                }
            }
            return(nodeExpr);
        }
Beispiel #20
0
 private string GetElementTextById(string id)
 {
     try
     {
         mshtml.IHTMLDocument2 doc2    = (mshtml.IHTMLDocument2)webBrowser1.Document;
         mshtml.IHTMLElement   element = doc2.all.item(id, 0);
         return(element.getAttribute("InnerText"));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Beispiel #21
0
 protected override bool OnPerform(WatiN.Core.Element element)
 {
     if (autoSubmit)
     {
         element.Click();
     }
     else
     {
         var nativeElement      = element.NativeElement as IEElement;
         mshtml.IHTMLElement el = nativeElement.AsHtmlElement;
         el.setAttribute("__recordmark", RecordMark ? "1" : "0");
     }
     return(true);
 }
Beispiel #22
0
        private void ClickElement(mshtml.IHTMLElement element, string innerText = null)
        {
            mshtml.IHTMLElement2 _el = element as mshtml.IHTMLElement2;
            _el.focus();

            if (innerText != null)
            {
                element.innerText = innerText;
            }
            else
            {
                Console.WriteLine("아이디 또는 비밀번호가 올바르지 않습니다.");
            }
        }
Beispiel #23
0
        public static mshtml.IHTMLElement getElementByTagName(
            this mshtml.IHTMLElement element,
            string tagName
            )
        {
            var elements = element.getElementsByTagName(tagName);

            if (elements.Count > 0)
            {
                return(elements[0]);
            }

            return(null);
        }
Beispiel #24
0
        public override System.Xml.XmlDocument doAction()
        {
            logger.Debug("Trying to retrieve Details for EAN code " + eanCode);

            // Search for EAN search field in the currently loaded page
            XmlDocument doc = getBrowserContents();

            // If not present (we are not on catalog page), load the catalog page until EAN search field appears.
            if (doc == null || doc.SelectSingleNode(eanFieldXPath) == null)
            {
                navigate(catalogueUrl, eanFieldXPath);
                // Wait also for the search button to appear
                navigate(null, XPath.get("bouton_rechercher"));
            }

            // Input EAN code & Press Search
            HtmlDocument          document     = getBrowserDocument();
            HtmlElementCollection inputs       = document.GetElementsByTagName("INPUT");
            HtmlElement           submitButton = null;

            foreach (HtmlElement elt in inputs)
            {
                if (XPath.get("id_champ_ean").Equals(elt.Id, StringComparison.InvariantCultureIgnoreCase))
                {
                    elt.SetAttribute("value", eanCode);
                }
                if ("submit".Equals(elt.GetAttribute("type"), StringComparison.InvariantCultureIgnoreCase))
                {
                    submitButton = elt;
                }
            }

            if (submitButton == null)
            {
                logger.Error("Can't find Search EAN button in the following catalog page HTML: " + getBrowserContents().InnerXml);
                throw new ConnectionFailedException("Le Bouton de recherche de la page du catalogue n'a pas été trouvé.");
            }

            // Press Search button
            mshtml.IHTMLElement iButton = (mshtml.IHTMLElement)submitButton.DomElement;
            iButton.click();

            // Wait for search result to be loaded.
            navigate(null, XPath.get("code_ean_html").Replace(Aide_Dilicom3.Properties.Settings.Default.EanToken, eanCode));

            // Return Document object for further parsing.
            return(getBrowserContents());
        }
Beispiel #25
0
        public IESelector(Browser browser, mshtml.IHTMLElement baseelement, IESelector anchor, bool doEnum, int X, int Y)
        {
            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();
            Log.Selector(string.Format("IEselector::AutomationElement::begin {0:mm\\:ss\\.fff}", sw.Elapsed));
            Log.Selector(string.Format("IEselector::GetControlViewWalker::end {0:mm\\:ss\\.fff}", sw.Elapsed));

            Clear();
            enumElements(browser, baseelement, anchor, doEnum, X, Y);

            Log.Selector(string.Format("IEselector::EnumNeededProperties::end {0:mm\\:ss\\.fff}", sw.Elapsed));
            OnPropertyChanged(new System.ComponentModel.PropertyChangedEventArgs("Count"));
            OnPropertyChanged(new System.ComponentModel.PropertyChangedEventArgs("Item[]"));
            OnCollectionChanged(new System.Collections.Specialized.NotifyCollectionChangedEventArgs(System.Collections.Specialized.NotifyCollectionChangedAction.Reset));
        }
        static public Point GetOffset(mshtml.IHTMLElement el)
        {
            //get element pos
            System.Drawing.Point pos = new System.Drawing.Point(el.offsetLeft, el.offsetTop);

            //get the parents pos
            mshtml.IHTMLElement tempEl = el.offsetParent;
            while (tempEl != null)
            {
                pos.X += tempEl.offsetLeft;
                pos.Y += tempEl.offsetTop;
                tempEl = tempEl.offsetParent;
            }

            return(pos);
        }
Beispiel #27
0
        public static string PRAP_GetOtherInsurancePaymentName(SHDocVw.InternetExplorer wb, SHDocVw.ShellWindows shells)
        {
            mshtml.HTMLDocument wbDoc = wb.Document;

            foreach (mshtml.IHTMLElement a in wbDoc.getElementsByTagName("a"))
            {
                if (a.innerText == "Third Party Liability")
                {
                    a.click();
                }
            }

            /*
             * find the table by document index of tables. if that table only has 1 row, the table is empty. otherwise, those rows should
             * be investigated for TPL payments
             *
             * Table[1] > TR[1]
             * foreach table in TR[1]
             *  table[0] > TR ID="claimBody" > td id="claimTab4" > table[0] > tr[3] > table[0] > *tr[1]*
             */
            // todo: test elements and values found
            mshtml.HTMLTableCell claimTabCell       = wb.Document.getElementById("claimTab4");
            mshtml.HTMLTable     otherInsTable      = claimTabCell.getElementsByTagName("table").item(0);
            mshtml.HTMLTableRow  otherInsTableRow   = otherInsTable.rows.item(3); //.getElementsByTagName("tr").item(4);
            mshtml.HTMLTableCell otherInshtableCell = otherInsTableRow.getElementsByTagName("td").item(0);
            mshtml.HTMLTable     oiSubTable         = otherInshtableCell.getElementsByTagName("table").item(0);

            foreach (mshtml.HTMLTableRow Row in oiSubTable.rows)
            {
                //Console.WriteLine("row counts of subTable: " + oiSubTable.rows.length);
                try
                {
                    mshtml.HTMLTable table = Row.getElementsByTagName("table").item(0);
                    otherInsTableRow = table.getElementsByTagName("tr").item(1);
                    table            = otherInsTableRow.getElementsByTagName("table").item(0);
                    otherInsTableRow = table.getElementsByTagName("tr").item(0);
                    mshtml.IHTMLElement oiName = otherInsTableRow.getElementsByTagName("a").item(0);
                    string carrier             = oiName.innerText;
                    //Console.WriteLine("carrier: " + carrier);
                    if (carrier != "")
                    {
                        return(carrier); //Console.WriteLine("OI found, provider: " + carrier);
                    }
                } catch (Exception) { Console.WriteLine("OI Exception"); return(null); }
            }
            return(null);
        }
Beispiel #28
0
        public ReplicaPage(string html)
        {
            Raw      = html;
            Supplier = new Dictionary <string, string>();
            var parser = new FMWW.Http.HTMLParser(html);

            mshtml.HTMLDocument           document = parser.Document;
            mshtml.IHTMLElementCollection inputs   = document.getElementsByTagName("input");
            foreach (mshtml.IHTMLElement elm in inputs)
            {
                string title = elm.getAttribute("title") ?? "";
                var    id    = elm.id ?? "";
                if ((title.Length == 0) || (id.Length == 0))
                {
                    continue;
                }
                string value = elm.getAttribute("value");
                Supplier.Add(title, value);
                Trace.WriteLine(String.Format("{0} {1} {2}", elm.id, title, value));

                try
                {
                    var input  = elm as mshtml.IHTMLInputElement;
                    var suffix = ":select";
                    var t      = title + suffix;
                    var v      = "";
                    mshtml.IHTMLElementCollection spans = document.getElementById(elm.id + suffix).children;
                    foreach (mshtml.IHTMLElement span in spans)
                    {
                        if (span.getAttribute("value") == input.value)
                        {
                            v = span.getAttribute("text");
                            continue;
                        }
                    }
                    Supplier.Add(t, v);
                    Trace.WriteLine(String.Format("{0} {1} {2}", elm.id + suffix, t, v));
                }
                catch (Exception e)
                {
                    Trace.WriteLine(e.Message);
                }
            }
            mshtml.IHTMLElement remark = document.getElementById("remark");
            Supplier.Add("備考", remark.innerText);
        }
Beispiel #29
0
        public EnhancedHtmlCheckBox GetEmbeddedCheckBox(int iRow, int iCol)
        {
            string sSearchProperties = "";

            mshtml.IHTMLElement td    = (mshtml.IHTMLElement)GetCell(iRow, iCol).UnWrap().NativeElement;
            mshtml.IHTMLElement check = GetEmbeddedCheckBoxNativeElement(td);
            string sOuterHTML         = check.outerHTML.Replace("<", "").Replace(">", "").Trim();

            string[]     saTemp = sOuterHTML.Split(' ');
            HtmlCheckBox chk    = new HtmlCheckBox(this.Control.Container);

            foreach (string sTemp in saTemp)
            {
                if (sTemp.IndexOf('=') > 0)
                {
                    string[] saKeyValue = sTemp.Split('=');
                    string   sValue     = saKeyValue[1];
                    if (saKeyValue[0].ToLower() == "name")
                    {
                        sSearchProperties += ";Name=" + sValue;
                        chk.SearchProperties.Add(HtmlControl.PropertyNames.Name, sValue);
                    }
                    if (saKeyValue[0].ToLower() == "id")
                    {
                        sSearchProperties += ";Id=" + sValue;
                        chk.SearchProperties.Add(HtmlControl.PropertyNames.Id, sValue);
                    }
                    if (saKeyValue[0].ToLower() == "class")
                    {
                        sSearchProperties += ";Class=" + sValue;
                        chk.SearchProperties.Add(HtmlControl.PropertyNames.Class, sValue);
                    }
                }
            }

            if (sSearchProperties.Length > 1)
            {
                sSearchProperties = sSearchProperties.Substring(1);
            }
            EnhancedHtmlCheckBox retChk = new EnhancedHtmlCheckBox(sSearchProperties);

            retChk.Wrap(chk);
            return(retChk);
        }
Beispiel #30
0
        /// <summary>
        /// Log in on Dilicom Web Site.
        ///
        /// We don't need to return one document, we just need to log in successfully.
        /// </summary>
        public override XmlDocument doAction()
        {
            // Display login page
            navigate(connectionUrl, Aide_Dilicom3.Config.XPath.get("detection_de_chargement_de_la_page_de_connexion"));

            // Input log & pass fields
            // Populating the forum to try the current login/password
            HtmlDocument          document     = getBrowserDocument();
            HtmlElementCollection inputs       = document.GetElementsByTagName("INPUT");
            HtmlElement           submitButton = null;

            foreach (HtmlElement elt in inputs)
            {
                if (elt.Id.Equals(XPath.get("id_champ_code"), StringComparison.InvariantCultureIgnoreCase))
                {
                    elt.SetAttribute("value", login);
                }
                if (elt.Id.Equals(XPath.get("id_champ_mot_de_passe"), StringComparison.InvariantCultureIgnoreCase))
                {
                    elt.SetAttribute("value", password);
                }
                if (elt.Id.Equals(XPath.get("id_bouton_ok"), StringComparison.InvariantCultureIgnoreCase))
                {
                    submitButton = elt;
                }
            }

            if (submitButton == null)
            {
                logger.Error("Can't find OK button to login (id = '" + XPath.get("id_bouton_ok") + "') in the following HTML: " + getBrowserContents().InnerXml);
                throw new ConnectionFailedException("Le Bouton OK du login et mot de passe n'a pas été trouvé.");
            }

            // Press login
            mshtml.IHTMLElement iButton = (mshtml.IHTMLElement)submitButton.DomElement;
            iButton.click();

            // Wait until the "connected" html token appears. If login & password are not correct, it's up to the end user to do something...
            navigate(null, XPath.get("detection_de_connexion"));


            // We don't do anything special.
            return(null);
        }
Beispiel #31
0
        public mshtml.IHTMLElement ElementFromPoint(mshtml.IHTMLElement frame, int X, int Y)
        {
            frame        = Document.elementFromPoint(X - elementx, Y - elementy);
            frameoffsetx = 0;
            frameoffsety = 0;
            bool isFrame = (frame.tagName == "FRAME");

            while (isFrame)
            {
                var web = frame as SHDocVw.IWebBrowser2;
                elementx     += frame.offsetLeft;
                elementy     += frame.offsetTop;
                frameoffsetx += frame.offsetLeft;
                frameoffsety += frame.offsetTop;
                //int elementw = el.offsetWidth;
                //int elementh = el.offsetHeight;

                var dd = (mshtml.HTMLDocument)web.Document;
                frame = dd.elementFromPoint(X - elementx, Y - elementy);
                if (frame == null)
                {
                    frame = dd.elementFromPoint(X, Y);
                }
                var tag  = frame.tagName;
                var html = frame.innerHTML;
                Log.Debug("tag: " + tag);
                Log.Debug("html: " + html);
                Log.Debug("-----");

                isFrame = (frame.tagName == "FRAME");
            }
            return(frame as mshtml.IHTMLElement);

            //mshtml.IHTMLElement htmlelement;
            //// Document = (mshtml.DispHTMLDocument)((SHDocVw.IWebBrowser2)frame).Document;
            //Document = (mshtml.HTMLDocument)((SHDocVw.IWebBrowser2)frame).Document;
            //elementx += frame.offsetLeft;
            //elementy += frame.offsetTop;
            //frameoffsetx += frame.offsetLeft;
            //frameoffsety += frame.offsetTop;
            //htmlelement = Document.elementFromPoint(X - elementx, Y - elementy);
            //if (htmlelement == null) throw new Exception("Nothing found at " + (X - elementx) + "," + (Y - elementy));
            //return htmlelement;
        }
 public MouseMoveHandler(mshtml.IHTMLDocument2 doc)
     : base(doc)
 {
     _el = null;
 }
Beispiel #33
0
 public HtmlControl(WATF.Core.Page.IPage page, mshtml.IHTMLElement elem)
 {
     this.m_Page = page;
     this.m_HtmlElement = elem;
 }
        private object mOldHandler; // store any existing handler that was replace by this one

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor fo object the OnHtmlElementEvent
        /// </summary>
        /// <param name="pHtmlEventHandler"></param>
        /// <param name="pElem">The mshtml.IHTMLElement we are handling the event on</param>
        /// <param name="pOldHandler">When you set an event, you replace any event that was already assigned. 
        /// You pass the current handler (value will be a COM Object type or System.DBNull) as the third 
        /// parameter of the OnHtmlElementEvent constructor so it can be called when an event occurs.</param>
        /// <param name="pEventType">The type of event that occured as a string. (onClick, onChange, etc.</param>
        public OnHtmlElementEvent(HtmlEventHandler pHtmlEventHandler, IHTMLElement2 pElem, object pOldHandler, string pEventType)
        {
            mElem = pElem as mshtml.IHTMLElement;
            mOldHandler = pOldHandler;
            mEventType = pEventType;
            mHandler = pHtmlEventHandler;
        }