Exemplo n.º 1
0
        public static void JavsScriptClick(string PageName, string ObjectName)
        {
            By OR_ObjectName = XML_Util.readObjectData(PageName, ObjectName);

            try
            {
                IWebElement         element  = driver.FindElement(OR_ObjectName);
                IJavaScriptExecutor executor = (IJavaScriptExecutor)driver;
                executor.ExecuteScript("arguments[0].click();", element);
                Test.TakeScreenShot();
            }
            catch (Exception e)
            {
                Logger.error("", e);
                Test.Result(ObjectName + " should be displayed in" + PageName + "Page", ObjectName + " is not  displayed in" + PageName + "Page", "Failed");

                //  Test.TakeScreenShot();
            }
            finally
            {
                Test.TakeScreenShot();
                if (driver.Url.ToLower().Contains("error"))
                {
                    Test.Result("Logout should be successful", "Un expected error while performing logout", "Failed");
                    Test.TakeScreenShot();
                }
                Logger.info("In " + PageName + "*-_-*-_-*-_-*" + ObjectName);
            }
        }
Exemplo n.º 2
0
        public static void Selectdropdown(string PageName, string ObjectName, string DropdownListText)
        {
            By OR_ObjectName = XML_Util.readObjectData(PageName, ObjectName);

            try
            {
                SelectElement select = new SelectElement(driver.FindElement(OR_ObjectName));

                foreach (IWebElement element in select.Options)
                {
                    if (element.Text == DropdownListText)
                    {
                        element.Click();
                    }
                }
            }
            catch (Exception e)
            {
                Logger.error("", e);
                Test.Result(ObjectName + "should be displayed in" + PageName + "Page", ObjectName + "is not  displayed in" + PageName + "Page", "Failed");

                Test.TakeScreenShot();
            }
            finally
            {
                Logger.info("In " + PageName + "*-_-*-_-*-_-*" + ObjectName);
            }
        }
Exemplo n.º 3
0
        public static bool VerifyText(string PageName, string ObjectName, string Expval)
        {
            bool result = false;

            try
            {
                By OR_ObjectName = XML_Util.readObjectData(PageName, ObjectName);

                string ExpValue = Expval.Trim().ToLower();
                // IWebElement Obj = driver.FindElement(OR_ObjectName);
                IWebElement Obj = WaitfortheElementPresent(OR_ObjectName);

                string Obj_text = Obj.Text.Trim().ToLower();
                if (Obj_text.Equals(ExpValue))
                {
                    Logger.info(ObjectName + " Text verfied");
                    result = true;
                    Console.WriteLine("VerifyText" + result);
                    Test.Result(ObjectName + " should be displayed in" + PageName + "Page", ObjectName + "is displayed in" + PageName + "Page", "Passed");
                }
                else
                {
                    result = false;
                    Logger.info(" ");
                    Test.Result(ObjectName + "should be displayed in" + PageName + "Page", ObjectName + "is not displayed in" + PageName + "Page", "Failed");
                }

                return(result);
            }
            catch (Exception e)
            {
                Logger.error("", e);
                result = false;
                Test.Result(ObjectName + "should be displayed in" + PageName + "Page", ObjectName + "is not displayed in" + PageName + "Page", "Failed");

                return(result);
            }
            finally
            {
                Logger.info("In" + PageName + "*-_-*-_-*-_-*" + ObjectName);
            }
        }
Exemplo n.º 4
0
        public static void EnterText(string PageName, string ObjectName, string TextBoxtext)
        {
            By OR_ObjectName = XML_Util.readObjectData(PageName, ObjectName);

            try
            {
                driver.FindElement(OR_ObjectName).SendKeys(TextBoxtext);
            }
            catch (Exception e)
            {
                Logger.error("", e);
                Test.Result(ObjectName + "should be displayed in" + PageName + "Page", ObjectName + "is not  displayed in" + PageName + "Page", "Failed");

                Test.TakeScreenShot();
            }
            finally
            {
                Logger.info("In " + PageName + "*-_-*-_-*-_-*" + ObjectName);
            }
        }
Exemplo n.º 5
0
        public static void IsPresent(string PageName, string ObjectName)
        {
            bool result        = false;
            By   OR_ObjectName = XML_Util.readObjectData(PageName, ObjectName);

            try
            {
                result = driver.FindElement(OR_ObjectName).Enabled;
                Console.WriteLine("IsPresent" + result);

                Test.Result(ObjectName + "should be displayed in" + PageName + "Page", ObjectName + "is displayed in" + PageName + "Page", "Passed");
            }
            catch (Exception e)
            {
                Logger.error("", e);
                Test.Result(ObjectName + "should be displayed in" + PageName + "Page", ObjectName + "is not displayed in" + PageName + "Page", "Failed");
            }
            finally
            {
                Logger.info("In" + PageName + "*-_-*-_-*-_-*" + ObjectName);
            }
        }
Exemplo n.º 6
0
        //UnderProgress
        public static void ValidateDropdownoptions(string PageName, string ObjectName, string DropdownListText)
        {
            By OR_ObjectName = XML_Util.readObjectData(PageName, ObjectName);

            try
            {
                IWebElement         element         = driver.FindElement(OR_ObjectName);
                IList <IWebElement> AllDropDownList = element.FindElements(OR_ObjectName);
                int DpListCount = AllDropDownList.Count;
            }
            catch (Exception e)
            {
                Logger.error("", e);
                Test.Result(ObjectName + "should be displayed in" + PageName + "Page", ObjectName + "is not  displayed in" + PageName + "Page", "Failed");

                Test.TakeScreenShot();
            }
            finally
            {
                Logger.info("In " + PageName + "*-_-*-_-*-_-*" + ObjectName);
            }
        }
Exemplo n.º 7
0
        public static void Click(string PageName, string ObjectName)
        {
            By OR_ObjectName = XML_Util.readObjectData(PageName, ObjectName);

            try
            {
                IWebElement Obj = WaitfortheElementPresent(OR_ObjectName);
                // driver.FindElement(OR_ObjectName).Click();
                if (Obj.Displayed)
                {
                    Obj.Click();
                }
                else
                {
                    ScrollDown(OR_ObjectName);

                    Obj.Click();
                }
            }
            catch (Exception e)
            {
                Logger.error(ObjectName + " is not found in " + PageName, e);

                Test.Result(ObjectName + " is not found in " + PageName, ObjectName + " is not found in " + PageName, "Failed");
                Test.TakeScreenShot();
            }
            finally
            {
                if (driver.Url.ToLower().Contains("error"))
                {
                    Test.Result("Logout should be successful", "Un expected error while performing logout", "Failed");
                    Test.TakeScreenShot();
                }
                Logger.info("In" + PageName + "*-_-*-_-*-_-*" + ObjectName);
            }
        }