コード例 #1
0
        internal void CommonUtilsPage(string name, string titleRead)
        {
            //Start the Reports
            Base.ExtentReports();
            Base.test = Base.extent.StartTest("Search Job Title to find Skill trader");
            Thread.Sleep(1000);
            try
            {
                //Simple Search
                SearchSkillBox.Click();
                SearchSkillBox.SendKeys(titleRead);
                SearchSkillBox.SendKeys(Keys.Enter);
                Thread.Sleep(1000);

                string expectedValue = name;
                string actualValue   = GlobalDefinitions.driver.FindElement(By.XPath("//a[contains(.,'" + name + "')]")).Text;
                Thread.Sleep(500);

                if (expectedValue == actualValue)
                {
                    // Screenshot
                    string img = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Report");
                    Base.test.Log(LogStatus.Info, "Snapshot below: " + Base.test.AddScreenCapture(img));
                    Base.test.Log(LogStatus.Pass, "Test Passed, Test Analyst searched Anna Jacob found Successfully");
                    Console.WriteLine("Listing added found");
                }

                else if (expectedValue != actualValue)
                {
                    Base.test.Log(LogStatus.Fail, "Test Failed");
                    Console.WriteLine("Listing not found test failed ");
                }

                //Complex search
                SearchLink.Click();
                Thread.Sleep(1000);
                SearchCategories.Click();
                SearchSubCategories.Click();
                SearchFilter.Click();
                if (expectedValue == actualValue)
                {
                    // Screenshot
                    string img = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Report");
                    Base.test.Log(LogStatus.Info, "Snapshot below: " + Base.test.AddScreenCapture(img));
                    Base.test.Log(LogStatus.Pass, "Test Passed, Test Analyst searched Anna Jacob found Successfully");
                    Console.WriteLine("Listing added found");
                }

                else if (expectedValue != actualValue)
                {
                    Base.test.Log(LogStatus.Fail, "Test Failed");
                    Console.WriteLine("Listing not found test failed ");
                }
            }
            catch (Exception e)
            {
                Global.Base.test.Log(LogStatus.Fail, "Test Failed", e.Message);
            }
        }