Пример #1
0
        public void DingDanGuanLiCase002()
        {
            try
            {
                Log.Info("开始执行用例");
                //打开首页
                baseURL = UserHT["url"].ToString();
                driver.Navigate().GoToUrl(baseURL);
                //登录
                LoginOn loginOn = new LoginOn(driver, LogWrite);
                loginOn.CNLoginOn(UserHT["测试用户登录名"].ToString(), UserHT["测试用户登陆密码"].ToString());

                Thread.Sleep(5000);

                //验证订单管理全部订单链接存在并点击
                Log.Info("验证订单管理全部订单链接");
                driver.FindElement(By.XPath("//ul/li/div[2]/dl[1]/dd[1]/a")).Click();
                Thread.Sleep(MinSleepTime);
                //验证跳转链接正确
                CtripAssert.Contains(driver, driver.FindElement(By.XPath("//ul/li/div[3]/div[3]/div[1]/h3")).Text, "待完成的订单", "验证跳转链接是否正确");
                //设置时间区间显示订单数
                TestLog.WriteLine("验证不同时间区间订单显示");
                TestLog.WriteLine("检查已完成订单");
                TestLog.WriteLine("检查最近一个月已完成订单数");
                String notendtext = driver.FindElement(By.Id("h3_contianerF")).Text;
                int    flagA      = int.Parse(notendtext.Substring(notendtext.IndexOf('(') + 1, notendtext.IndexOf(')') - notendtext.IndexOf('(') - 1));
                CtripAssert.IsTrue(driver, flagA >= 0);
                TestLog.WriteLine("检查最近三个月已完成订单数");
                SeleniumFun.SelectByText(driver.FindElement(By.Id("sel_orderrange")), "最近3个月订单");
                Thread.Sleep(MIDSleepTime);
                int flagB = int.Parse(notendtext.Substring(notendtext.IndexOf('(') + 1, notendtext.IndexOf(')') - notendtext.IndexOf('(') - 1));
                CtripAssert.IsTrue(driver, flagB >= flagA);
                TestLog.WriteLine("检查最近一年已完成订单数");
                SeleniumFun.SelectByText(driver.FindElement(By.Id("sel_orderrange")), "最近1年订单");
                Thread.Sleep(MIDSleepTime);
                int flagC = int.Parse(notendtext.Substring(notendtext.IndexOf('(') + 1, notendtext.IndexOf(')') - notendtext.IndexOf('(') - 1));
                CtripAssert.IsTrue(driver, flagC >= flagA);
            }
            catch (Exception e)
            {
                new CtripException(driver, e.ToString(), this.GetType().ToString(), MethodBase.GetCurrentMethod().ToString());
            }
        }