//Add new Lanuguage
        internal void Addlanguage()
        {
            //explicit wait
            GlobalDefinitions.WaitForClickableElement(driver, By.XPath("//a[text()='Languages']"), 30);

            //firstly click on language button
            LanguageButton.Click();

            //implicit wait
            GlobalDefinitions.wait(30);

            //click on add new button
            AddNewLanguage.Click();


            GlobalDefinitions.wait(30);
            //enter text in language field
            LanguageText.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Language"));

            //select level from drop down

            new SelectElement(driver.FindElement(By.XPath("//select[@class='ui dropdown']"))).SelectByValue(GlobalDefinitions.ExcelLib.ReadData(2, "LanguageLevel"));

            GlobalDefinitions.wait(30);

            //click on add button
            AddLanguage.Click();

            GlobalDefinitions.wait(30);
        }
        //Delete a given language
        internal void DeleteLanguage()
        {
            //explicit wait
            GlobalDefinitions.WaitForClickableElement(driver, By.XPath("//a[text()='Languages']"), 30);

            LanguageButton.Click();

            //expected value of language
            String expectedValue  = GlobalDefinitions.ExcelLib.ReadData(2, "Language");
            String expectedValue1 = GlobalDefinitions.ExcelLib.ReadData(3, "Language");
            //Get the table row list
            IList <IWebElement> Tablerows = (IList <IWebElement>)driver.FindElements(By.XPath("//form/div[2]/div/div[2]/div/table/tbody/tr"));

            //Count how many rows
            var rowCount = Tablerows.Count;

            for (int i = 1; i <= rowCount; i++)
            {
                //xpath of ith languagename(row)
                String actualValue = driver.FindElement(By.XPath("//div/table/tbody[" + i + "]/tr/td[1]")).Text;

                if ((expectedValue == actualValue) || (expectedValue1 == actualValue))
                {     //click on delete icon
                    driver.FindElement(By.XPath("//div/table/tbody[" + i + "]/tr/td[3]/span[2]/i")).Click();

                    Console.WriteLine("Langugae deleted");

                    break;
                }
            }
        }
        //update Language
        internal void UpdateLanguage()
        {
            GlobalDefinitions.wait(30);
            LanguageButton.Click();
            GlobalDefinitions.wait(30);
            //click the pen icon to edit
            driver.FindElement(By.XPath("//table/tbody[1]/tr[last()]/td[3]/span[1]/i")).Click();
            //clear existing text
            IWebElement Language = driver.FindElement(By.XPath("//input[@placeholder='Add Language']"));

            Language.Clear();
            Language.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "Language"));
            //click update button
            driver.FindElement(By.XPath("//input[@value='Update']")).Click();
            GlobalDefinitions.wait(30);
        }
示例#4
0
        //Validate update language

        internal void ValidateUpdateLanguage()
        {
            try
            {
                //check language
                LanguageButton.Click();

                ExtentionHelpers.TurnOnWait(driver);

                //Lanuguage text
                //String Lang = Driver.driver.FindElement(By.XPath("//a[@class='item'][contains(.,'Languages')]")).Text;
                String Lang = driver.FindElement(By.XPath("(//div[@data-tab='first']//table//tbody//tr[1]//td[1])[1]")).Text;

                //Level Text
                String level = driver.FindElement(By.XPath("(//div[@data-tab='first']//table//tbody//tr[1]//td[2])[1]")).Text;

                //Assertions
                Assert.Multiple(() =>
                {
                    ExcelLibHelper.PopulateInCollection(ConstantHelpers.TestDataPath, "FieldValues");
                    Assert.AreEqual(Lang, ExcelLibHelper.ReadData(4, "Language"));
                    Assert.AreEqual(level, "Basic");
                });


                SaveScreenShotClass save = new SaveScreenShotClass();
                string img = save.SaveScreenshot(driver, "LanguageUpdate");

                Console.WriteLine("Assertion pass");
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }