public void GotoHomePage()
        {
            string baseURL = Helps.GetConfigurationValue("EduSohoHomePageURL");

            webDriver.Navigate().GoToUrl(baseURL);
            context["webdriver"] = webDriver;
        }
Exemplo n.º 2
0
 protected void Addhelp_Click(object sender, EventArgs e)
 {
     #region 增加帮助项
     if (this.CheckCookie())
     {
         if (int.Parse(type.SelectedItem.Value) == 0)
         {
             base.RegisterStartupScript("", "<script>alert('您未选中任何选项');window.location.href='global_addhelp.aspx';</script>");
         }
         else
         {
             Helps.addhelp(tbtitle.Text, message.Text, int.Parse(type.SelectedItem.Value));
             Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/AnnouncementList");
             AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "添加帮助", "添加帮助,标题为:" + tbtitle.Text);
     #if NET1
             if (!base.IsStartupScriptRegistered("page"))
             {
                 base.RegisterStartupScript("", "<script>window.location.href='global_helplist.aspx';</script>");
             }
     #else
             base.RegisterStartupScript("", "<script>window.location.href='global_helplist.aspx';</script>");
     #endif
         }
     }
     #endregion
 }
        public void ThenNewShouldBeFoundInTheArticleCategoryPage(string code)
        {
//            Thread.Sleep(5000);
            IWebElement Table  = Helps.GetIWebElementBy(driver, By.Id("category-table"));
            var         rows   = Table.FindElements(By.ClassName("tr"));
            Boolean     finded = false;

            foreach (var row in rows)
            {
                var cells = row.FindElements(By.ClassName("td"));
                if (cells.Count == 0)
                {
                    continue;
                }
                int cellindex = 0;
                foreach (var cell in cells)
                {
                    if (cell.GetAttribute("class").Contains("code"))
                    {
                        if (cell.Text == code)
                        {
                            finded = true;
                            break;
                        }
                    }
                    cellindex++;
                }
                if (finded == true)
                {
                    break;
                }
            }
            Assert.IsTrue(finded, "test failed due to new added category code does not show in category table.");
        }
Exemplo n.º 4
0
        /// <summary>
        /// delete the article category by name
        /// </summary>
        /// <param name="categoryName"></param>
        public void DeleteTheCategoryByCode(string categoryCode)
        {
            IWebElement Table    = webDriver.FindElement(By.Id("category-table"));
            var         rows     = Table.FindElements(By.ClassName("tr"));
            int         rowIndex = 0;

            foreach (var row in rows)
            {
                var cells = row.FindElements(By.ClassName("td"));
                if (cells.Count == 0)
                {
                    continue;
                }
                int cellindex = 0;
                foreach (var cell in cells)
                {
                    if (cell.GetAttribute("class").Contains("code"))
                    {
                        if (cell.Text == categoryCode)
                        {
                            cells[cellindex + 1].FindElements(By.ClassName("btn-sm"))[0].Click();
                            Helps.ClickOperation(webDriver, By.ClassName("delete-category"));
                            IAlert alert = webDriver.SwitchTo().Alert();
                            alert.Accept();
                            Thread.Sleep(3000);
                            return;
                        }
                    }
                    cellindex++;
                }
                rowIndex++;
            }
        }
Exemplo n.º 5
0
        public void LoginErrMsgDisplayed(string expectMsg, string labelName)
        {
            By by = null;

            switch (labelName)
            {
            case "email":
                by = By.Id("register_email-error");
                break;

            case "username":
                by = By.Id("register_nickname-error");
                break;

            case "password":
                by = By.Id("register_password-error");
                break;

            case "captchaCode":
                by = By.Id("captcha_code-error");
                break;

            case "userterm":
                by = By.Id("userterms-error");
                break;
            }
            Helps.LabelShowMsgAsExpected(webDriver, by, expectMsg, labelName);
        }
        public void WhenIModifyTheCategoryNameToNewOne(string name, string newName)
        {
            IWebElement Table = driver.FindElement(By.Id("category-table"));
            var         rows  = Table.FindElements(By.ClassName("tr"));

            foreach (var row in rows)
            {
                int cellindex = 0;
                var cells     = row.FindElements(By.ClassName("td"));
                foreach (var cell in cells)
                {
                    if (cell.GetAttribute("class").Contains("name"))
                    {
                        if (cell.Text == name)
                        {
                            cells[cellindex + 3].FindElements(By.ClassName("btn-sm"))[0].Click();
                            Helps.InputClearAndStringOperation(driver, By.Id("category-name-field"), newName);
                            Helps.SubmitOperation(driver, By.Id("category-save-btn"));
                            return;
                        }
                    }
                    cellindex++;
                }
            }
        }
        /// <summary>
        /// return the counts of rows
        /// if the result is empty then return the first row[0]
        /// </summary>
        /// <returns></returns>
        public string GetResultCountOfTable()
        {
            string rowcountStr   = "";
            var    tbody         = Helps.GetIWebElementBy(webDriver, By.Id("order-table")).FindElement(By.TagName("tbody"));
            var    rows          = tbody.FindElements(By.TagName("tr"));
            var    firstRowItems = rows[0].FindElements(By.TagName("td"));

            if (rows.Count == 1 && firstRowItems.Count == 1)
            {
                return(firstRowItems[0].Text);
            }
            else
            {
                rowcountStr = rows.Count.ToString();
                if (rowcountStr == "20")
                {
                    try
                    {
                        string s              = Helps.GetTextFromElement(webDriver, By.ClassName("page-num"));
                        int    startIndex     = s.IndexOf('/') + 1;
                        string totalNumberStr = s.Substring(startIndex, s.Length - startIndex).Trim();
                        return(totalNumberStr);
                    }
                    catch (Exception)
                    {
                        return("20");
                    }
                }
                else
                {
                    return(rowcountStr);
                }
            }
        }
        public void GivenIAmInPage(string pageName)
        {
            string baseURL = Helps.GetConfigurationValue(pageName);

            driver.Navigate().GoToUrl(baseURL);
            context["webdriver"] = driver;
        }
Exemplo n.º 9
0
        public void Help(Form _MdiForm)
        {
            Helps Help = new Helps();

            Help.MdiParent = _MdiForm;
            Help.Show();
        }
Exemplo n.º 10
0
        public async Task <IActionResult> PutHelp(string individualid, long needid, Helps help)
        {
            if (needid != help.NeedID || help.IndividualID != individualid)
            {
                return(BadRequest());
            }

            _context.Entry(help).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HelpsExists(individualid, needid))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public void ScenarioTearDown()
        {
            string baseURL = Helps.GetConfigurationValue("EduSohoHomePageURL");

            driver.Navigate().GoToUrl(baseURL);
            context["webdriver"] = driver;
        }
Exemplo n.º 12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     helpinfo = Helps.GetMessage(id);
     if (helpinfo.Pid == 0)
     {
         Response.Redirect("global_edithelpclass.aspx?id=" + id);
         return;
     }
     if (!Page.IsPostBack)
     {
         if ((this.username != null) && (this.username != ""))
         {
             if (id == 0)
             {
                 return;
             }
             poster.Text = this.username;
             type.AddTableData(Helps.GetHelpTypes(), "title", "id");
             type.SelectedValue      = helpinfo.Pid.ToString();
             orderby.Text            = helpinfo.Orderby.ToString();
             title.Text              = helpinfo.Title;
             help.Text               = helpinfo.Message;
             updatehelp.ValidateForm = true;
             title.AddAttributes("maxlength", "200");
             title.AddAttributes("rows", "2");
             type.DataBind();
         }
     }
 }
Exemplo n.º 13
0
        private void Orderby_Click(object sender, EventArgs e)
        {
            #region 排序
            string[] orderlist = DNTRequest.GetFormString("orderbyid").Split(',');
            string[] idlist    = DNTRequest.GetFormString("hidid").Split(',');

            if (!Helps.UpOrder(orderlist, idlist))
            {
                base.RegisterStartupScript("", "<script>alert('输入错误,排序号只能是数字');window.location.href='global_helplist.aspx';</script>");
                return;
            }
            //foreach (string s in orderlist)
            //{
            //    if (Utils.IsNumeric(s) == false)
            //    {
            //        base.RegisterStartupScript("", "<script>alert('输入错误,排序号只能是数字');window.location.href='global_helplist.aspx';</script>");
            //        return;
            //    }
            //}

            //for (int i = 0; i < idlist.Length; i++)
            //{
            //    Helps.UpOrder(orderlist[i].ToString(), idlist[i].ToString());
            //}

            base.RegisterStartupScript("", "<script>window.location.href='global_helplist.aspx';</script>");
            #endregion
        }
Exemplo n.º 14
0
        public async Task <ActionResult <Helps> > PostHelps(Helps help)
        {
            _context.Helps.Add(help);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetHelps", new { needid = help.NeedID, individualid = help.IndividualID }, help));
        }
Exemplo n.º 15
0
 /// <summary>
 /// click pop up menue items
 /// </summary>
 public IWebDriver GotoPersonalManage(string menuName)
 {
     HoverOnAvatar();
     Thread.Sleep(500);
     Helps.ClickOperation(webDriver, By.LinkText(menuName));
     context["webdriver"] = webDriver;
     return(webDriver);
 }
Exemplo n.º 16
0
        public void HoverOnAvatar()
        {
            Actions builder = new Actions(webDriver);
            Actions hover   = builder.MoveToElement(Helps.GetIWebElementBy(webDriver, By.ClassName("avatar-xs")));

            hover.Build().Perform();
            Thread.Sleep(500);
        }
Exemplo n.º 17
0
        public void GivenIClickLinktext(string p0)
        {
            driver = (IWebDriver)context["webdriver"];
            By by = By.LinkText(p0);

            Helps.ClickOperation(driver, by);
            context["webdriver"] = driver;
        }
Exemplo n.º 18
0
 protected void del(string idlist)
 {
     #region  除帮助
     Helps.DelHelp(idlist);
     AdminVistLogs.InsertLog(userid, username, usergroupid, grouptitle, ip, "删除帮助", "删除帮助,帮助ID为: " + DNTRequest.GetString("id"));
     Response.Redirect("global_helplist.aspx");
     #endregion
 }
 /// <summary>
 /// enter in the 关键词
 /// </summary>
 public void KeywordEnter(string input)
 {
     if (input == "")
     {
         return;
     }
     Helps.InputClearAndStringOperation(webDriver, By.Name("keyword"), input);
     Helps.clickBlankArea(webDriver);
 }
Exemplo n.º 20
0
 protected void del(string idlist)
 {
     #region  除帮助
     Helps.delhelp(idlist);
     Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/helplist");
     AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "删除帮助", "删除帮助,帮助ID为: " + DNTRequest.GetString("id"));
     Response.Redirect("global_helplist.aspx");
     #endregion
 }
Exemplo n.º 21
0
        public void BeforeScenario(ScenarioContext scenarioContext)
        {
            Console.WriteLine("BeforeScenario");
            scenario = featureName.CreateNode <Scenario>(scenarioContext.ScenarioInfo.Title);
            string baseURL = Helps.GetConfigurationValue("EduSohoHomePageURL");

            driver.Navigate().GoToUrl(baseURL);
            scenarioContext["webdriver"] = driver;
        }
Exemplo n.º 22
0
 private void AddHelp(Result result)
 {
     for (int i = 0; i < result.infoHelp.Count; i++)
     {
         Helps.Add(new Helps {
             help = result.infoHelp[i]
         });
     }
 }
        public void GivenIAmInRegisterPage()
        {
            string baseURL = Helps.GetConfigurationValue("EduSohoRegisterPageURL");

            driver = new FirefoxDriver();
            driver.Navigate().GoToUrl(baseURL);
            context["webdriver"] = driver;
            registerPage         = new EduSohoRegisterPage(context);
        }
Exemplo n.º 24
0
        public void ShouldDisplayMsgAt(string fieldName, string inputStr)
        {
            By by = null;

            switch (fieldName)
            {
            case "真实姓名":
                by = By.Id("profile_truename-error");
                break;

            case "性别":
                by = By.Name("profile[gender]-error");
                break;

            case "身份证号码":
                by = By.Id("profile_idcard-error");
                break;

            case "手机号码":
                by = By.Id("profile_mobile-error");
                break;

            case "公司":
                by = By.Id("profile_company-error");
                break;

            case "职业":
                by = By.Id("profile_job-error");
                break;

            case "头衔":
                by = By.Id("profile_title-error");
                break;

            case "个人签名":
                by = By.Id("profile_signature-error");
                break;

            case "自我介绍":
                by = By.ClassName("cke_editable_themed-error");
                break;

            case "个人空间":
                by = By.Id("profile_site-error");
                break;

            case "微博":
                by = By.Id("weibo-error");
                break;

            case "QQ":
                by = By.Id("profile_qq-error");
                break;
            }
            Helps.LabelShowMsgAsExpected(webDriver, by, inputStr, fieldName);
        }
Exemplo n.º 25
0
        public void EnterOneTableRecordToPersonalBasicInfoPage(string fieldName, string inputStr)
        {
            switch (fieldName)
            {
            case "真实姓名":
                TruenameEnter(inputStr);
                break;

            case "性别":
                SexSelect(inputStr);
                break;

            case "身份证号码":
                IdcardEnter(inputStr);
                break;

            case "手机号码":
                MobileEnter(inputStr);
                break;

            case "公司":
                CompanyEnter(inputStr);
                break;

            case "职业":
                JobEnter(inputStr);
                break;

            case "头衔":
                TitleEnter(inputStr);
                break;

            case "个人签名":
                SignatureEnter(inputStr);
                Helps.clickBlankArea(webDriver);
                break;

            case "自我介绍":
                IntroductionEnter(inputStr);
                Helps.clickBlankArea(webDriver);
                break;

            case "个人空间":
                SiteEnter(inputStr);
                break;

            case "微博":
                WeiboEnter(inputStr);
                break;

            case "QQ":
                QQEnter(inputStr);
                break;
            }
        }
Exemplo n.º 26
0
 protected void add_Click(object sender, EventArgs e)
 {
     #region 增加帮助类别
     if (this.CheckCookie())
     {
         Helps.AddHelp(title.Text, "", 0);
         AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "添加帮助分类", "添加帮助分类,标题为:" + title.Text);
         base.RegisterStartupScript("", "<script>window.location.href='global_helplist.aspx';</script>");
     }
     #endregion
 }
Exemplo n.º 27
0
        /// <summary>
        /// 将image对象以指定的文件名、格式 保存到指定目录
        /// </summary>
        /// <param name="directoryPath">目录</param>
        /// <param name="fileName">文件名</param>
        /// <param name="image">图片</param>
        /// <param name="imageFormat">图片格式</param>
        /// <returns></returns>
        public static string Save(string directoryPath, string fileName, Image image, ImageFormat imageFormat)
        {
            // 保存到指定文件
            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }
            string fielPath = Helps.PathCombine(directoryPath, fileName);

            image.Save(fielPath, imageFormat);
            return(fielPath);
        }
Exemplo n.º 28
0
        /// <summary>
        /// input the Sex
        /// </summary>
        public void SexSelect(string inputStr = "男")
        {
            //WebDriverWait wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(10));
            //wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.Name("profile[gender]")));

            //foreach (var element in sexRadioBx)
            //{
            //    if (element.GetAttribute("value") == inputStr)
            //        element.Click();
            //}
            Helps.SelectFromRadioOperation(webDriver, By.Name("profile[gender]"), inputStr);
        }
 /// <summary>
 /// enter in the 结束时间
 /// </summary>
 public void EndTimeEnter(string input)
 {
     if (input == "")
     {
         return;
     }
     Helps.InputClearAndStringOperation(webDriver, By.Id("endDate"), input);
     Helps.InputAddingStringOperation(webDriver, By.Id("endDate"), Keys.Enter);
     Helps.InputAddingStringOperation(webDriver, By.Id("endDate"), Keys.Enter);
     Helps.InputAddingStringOperation(webDriver, By.Id("endDate"), Keys.Enter);
     //            Helps.clickBlankArea(webDriver);
 }
Exemplo n.º 30
0
        /// <summary>
        //自我介绍
        //public IWebElement txtIntroduction => webDriver.FindElement(By.ClassName("cke_editable_themed"));
        /// </summary>
        public void IntroductionEnter(string inputStr)
        {
            WebDriverWait wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(10));

            wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.TagName("iframe")));
            webDriver.SwitchTo().Frame(0);
            //wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.ClassName("cke_editable_themed")));
            //txtIntroduction.Clear();
            //txtIntroduction.SendKeys(inputStr);
            Helps.InputClearAndStringOperation(webDriver, By.ClassName("cke_editable_themed"), inputStr);
            Helps.InputAddingStringOperation(webDriver, By.ClassName("cke_editable_themed"), Keys.Tab);
            webDriver.SwitchTo().ParentFrame();
        }