示例#1
0
        public bool Run(string fullcommand)
        {
            Match  match   = Regex.Match(fullcommand, "click\\('([^']+)',(\\d+),(\\d+)\\)");
            string element = match.Groups[1].Value;
            int    left    = Convert.ToInt32(match.Groups[2].Value);
            int    top     = Convert.ToInt32(match.Groups[3].Value);
            //MessageBox.Show(element + left.ToString() + top.ToString());
            bool success = false;

            if (CheckVisible.Instance().Run("checkvisible('" + element + "')"))
            {
                Browser.ChromeBrowser.EvaluateScriptAsync("document.querySelector('" + element + "').scrollIntoView();");
                Thread.Sleep(100);
                Browser.ChromeBrowser.EvaluateScriptAsync("window.scrollBy(0, -" + (Browser.ChromeBrowser.Height / 2).ToString() + ");");
                Thread.Sleep(500);
                int x = Convert.ToInt32(Convert.ToDecimal(EvaluateJavascript.Instance().Run("document.querySelector('" + element + "').getBoundingClientRect().x;")));
                int y = Convert.ToInt32(Convert.ToDecimal(EvaluateJavascript.Instance().Run("document.querySelector('" + element + "').getBoundingClientRect().y;")));
                if (x != 0 && y != 0)
                {
                    Browser.ChromeBrowser.GetBrowser().GetHost().SendMouseClickEvent(x + left, y + top, MouseButtonType.Left, false, 1, CefEventFlags.None);
                    Thread.Sleep(100);
                    Browser.ChromeBrowser.GetBrowser().GetHost().SendMouseClickEvent(x + left, y + top, MouseButtonType.Left, true, 1, CefEventFlags.None);
                    success = true;
                }
            }
            //MessageBox.Show("click success:" + success.ToString());
            return(success);
        }
示例#2
0
        public bool Run(string fullcommand)
        {
            MatchCollection coll       = Regex.Matches(fullcommand, "^javascript\\('([^']+)'\\)");
            string          javascript = coll[0].Groups[1].Value;

            EvaluateJavascript.Instance().Run(javascript);
            return(true);
        }
示例#3
0
        public bool Run(string fullcommand)
        {
            bool            ok         = false;
            MatchCollection coll       = Regex.Matches(fullcommand, "^int\\('([^']+)'\\)([>=<]{1,2})(\\d+)");
            string          javascript = coll[0].Groups[1].Value;
            string          bieuthuc   = coll[0].Groups[2].Value;
            int             so         = Convert.ToInt32(coll[0].Groups[3].Value);
            int             so2        = Convert.ToInt32(Convert.ToDecimal(EvaluateJavascript.Instance().Run(javascript)));

            switch (bieuthuc)
            {
            case ">":
                if (so2 > so)
                {
                    ok = true;
                }
                break;

            case ">=":
                if (so2 >= so)
                {
                    ok = true;
                }
                break;

            case "==":
                if (so2 == so)
                {
                    ok = true;
                }
                break;

            case "<=":
                if (so2 <= so)
                {
                    ok = true;
                }
                break;

            case "<":
                if (so2 < so)
                {
                    ok = true;
                }
                break;

            default:
                break;
            }
            return(ok);
        }
示例#4
0
        public bool Run(string fullcommand)
        {
            //MessageBox.Show("checkvisible: " + fullcommand);
            MatchCollection coll    = Regex.Matches(fullcommand, "checkvisible\\('([^']+)'\\)");
            string          element = coll[0].Groups[1].Value;
            //MessageBox.Show("checkvisible element: " + element);
            bool Visible = false;
            int  width   = Convert.ToInt32(Convert.ToDecimal(EvaluateJavascript.Instance().Run("document.querySelector('" + element + "').getBoundingClientRect().width;")));
            int  height  = Convert.ToInt32(Convert.ToDecimal(EvaluateJavascript.Instance().Run("document.querySelector('" + element + "').getBoundingClientRect().height;")));

            if (width != 0 && height != 0)
            {
                Visible = true;
            }
            return(Visible);
        }
示例#5
0
        public bool Run(string fullcommand)
        {
            //MessageBox.Show(fullcommand);
            bool            ok         = false;
            MatchCollection coll       = Regex.Matches(fullcommand, "^string\\('([^']+)'=='([^']+)'\\)");
            string          javascript = coll[0].Groups[1].Value;
            string          bieuthuc   = coll[0].Groups[2].Value;
            //MessageBox.Show(javascript +" "+ bieuthuc);
            string result = EvaluateJavascript.Instance().Run(javascript);

            //MessageBox.Show("result " + result);
            if (result != null && Regex.IsMatch(result, bieuthuc))
            {
                ok = true;
            }
            return(ok);
        }