Пример #1
0
        private bool LoginWeiBo(IWebDriver webDriver, string wbzh, string wbmima)
        {
            bool flag;
            int  i = 0;

            while (true)
            {
                if (i < 20)
                {
                    webDriver.FinElementAndInput(By.Id("userId"), wbzh, null);
                    webDriver.FinElementAndInput(By.Id("passwd"), wbmima, null);
                    Thread.Sleep(3000);
                    webDriver.FinElementAndInput(By.Id("vcode"), null, () => {
                        byte[] tupianByte = this.GetPicCodeData();
                        string picCode    = base.PicDati(tupianByte);
                        PicDaTiHelper.SavePic(tupianByte, "null", picCode, "bmp");
                        return(picCode);
                    });
                    if (webDriver.FindAndRandomClickElement(webDriver, By.ClassName("WB_btn_login")) != null)
                    {
                        if (webDriver.Wait(new Func <By, IWebElement>(webDriver.FindAndClickElement), By.ClassName("WB_btn_link")) == null)
                        {
                            XTrace.WriteLine("连接按钮找不到,可能已连接到虎牙");
                        }
                        if (webDriver.Wait(new Func <By, IWebElement>(webDriver.FinElement), By.Id("userId")) == null)
                        {
                            flag = true;
                            break;
                        }
                        else
                        {
                            i++;
                        }
                    }
                    else
                    {
                        XTrace.WriteLine("登录按钮找不到");
                        flag = false;
                        break;
                    }
                }
                else
                {
                    flag = false;
                    break;
                }
            }
            return(flag);
        }
Пример #2
0
        public PointX GetPoint4LianZhong(string bigPicSrc, string smallPicSrc, out PointX bigYuan, out PointX samllYuan)
        {
            int yuanWidth;
            int yuanHidth;
            int smW;
            int smH;

            byte[] bigPicByte = ImageHelper.Base64ToImage(bigPicSrc, out yuanWidth, out yuanHidth);
            bigYuan = new PointX()
            {
                X = yuanWidth,
                Y = yuanHidth
            };
            byte[] smallPicByte = ImageHelper.Base64ToImage(smallPicSrc, out smW, out smH);
            samllYuan = new PointX()
            {
                X = smW,
                Y = smH
            };
            PointX p = null;

            if ((bigPicByte == null || (int)bigPicByte.Length <= 10 || smallPicByte == null ? false : (int)smallPicByte.Length > 10))
            {
                JsDaTi dtMgr = new JsDaTi();
                if (dtMgr.GetZuoBiao(bigPicByte, 1318))
                {
                    p = new PointX()
                    {
                        X = dtMgr.offsetX,
                        Y = dtMgr.offsetY
                    };
                }
            }
            int rd = HelperGeneral.Random.Next(1, 9999999);

            PicDaTiHelper.SavePic(bigPicByte, "null", string.Format("big_{0}_{1}_{2}", p.X, p.Y, rd), "bmp");
            PicDaTiHelper.SavePic(smallPicByte, "null", string.Format("small_{0}_{1}_{2}", p.X, p.Y, rd), "bmp");
            return(p);
        }