Esempio n. 1
0
        public void Listings()
        {
            GlobalDefinitions.Wait();
            ManageListingsLink.Click();
            //Checking the right page
            Assert.AreEqual("ListingManagement", GlobalDefinitions.driver.Title);
            Base.test = Base.extent.StartTest("On Share Manage Listing page");
            edit.Click();
            //Populate the Excel Sheet
            Global.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill");
            Title.SendKeys(ExcelLib.ReadData(3, "Title"));
            GenericMethods.CheckLength(4, 100, ExcelLib.ReadData(3, "Title"), "Title");
            Description.SendKeys(ExcelLib.ReadData(3, "Description"));
            GenericMethods.CheckLength(4, 600, ExcelLib.ReadData(3, "Description"), "Description");
            CategoryDropDown.SendKeys(ExcelLib.ReadData(3, "Category"));
            SubCategoryDropDown.SendKeys(ExcelLib.ReadData(3, "SubCategory"));

            TxtTags.SendKeys(ExcelLib.ReadData(3, "Tags"));
            TxtTags.SendKeys(Keys.Enter);
            IWebElement ServiceTypeOptions = GlobalDefinitions.driver.FindElement(By.XPath("//div[5]//div[2]//div[1]//div[2]//div[1]//input[1]"));

            ServiceTypeOptions.Click();

            IWebElement LocationTypeOption = GlobalDefinitions.driver.FindElement(By.XPath("//div[6]//div[2]//div[1]//div[2]//div[1]//input[1]"));

            LocationTypeOption.Click();

            StartDateDropDown.SendKeys(ExcelLib.ReadData(2, "Startdate"));
            EndDateDropDown.SendKeys(ExcelLib.ReadData(2, "Enddate"));

            for (int i = 2; i < 9; i++)
            {
                for (int j = 2; j < 9; j++)
                {
                    IWebElement StartTime = GlobalDefinitions.driver.FindElement(By.XPath("//div[" + i + "]/div[2]/input"));
                    IWebElement EndTime   = GlobalDefinitions.driver.FindElement(By.XPath("//div[" + j + "]/div[3]/input"));
                    if (i == 2 && j == 2)
                    {
                        GlobalDefinitions.driver.FindElement(By.XPath("//div[contains(@class,'twelve wide column')]//div[2]//div[1]//div[1]//input[1]")).Click();
                        StartTime.SendKeys("0230PM");
                        StartTime.SendKeys(Keys.Tab);
                        EndTime.SendKeys("3052PM");
                    }
                    if (i == 3 && j == 3)
                    {
                        GlobalDefinitions.driver.FindElement(By.XPath("//div[3]//div[1]//div[1]//input[1]")).Click();
                        StartTime.SendKeys("0530PM");
                        EndTime.SendKeys("0856PM");
                    }
                }
            }

            IWebElement credit = GlobalDefinitions.driver.FindElement(By.XPath("//div[8]//div[2]//div[1]//div[2]//div[1]//input[1]"));

            if (!credit.Selected)
            {
                credit.Click();
                CreditAmount.SendKeys("9");
            }


            WorkSample.Click();

            AutoItX3 autoIt = new AutoItX3();

            autoIt.WinWait("Open", "File Upload", 1);

            autoIt.WinActivate("Open", "File Upload");

            autoIt.ControlFocus("Open", "File Upload", "[CLASS:Edit; INSTANCE:1]");

            autoIt.Send(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..")) + "\\Test.txt");                                 //autoIt

            autoIt.Send("{ENTER}");
            autoIt.Sleep(1000);

            IWebElement ActiveOption = GlobalDefinitions.driver.FindElement(By.XPath("//form/div[10]/div[@class='twelve wide column']/div/div[@class = 'field']"));

            ActiveOption.Click();
            GlobalDefinitions.Wait();
            Save.Click();
            GlobalDefinitions.Wait();
            Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Skills edited succesfully");
            string searchInput1 = GlobalDefinitions.driver.FindElement(By.XPath("//tbody//tr[1]//td[2]")).Text;

            Assert.AreEqual(searchInput1, ExcelLib.ReadData(3, "Category"));
            string searchInput2 = GlobalDefinitions.driver.FindElement(By.XPath("//tbody//tr[1]//td[3]")).Text;

            Assert.AreEqual(searchInput2, ExcelLib.ReadData(3, "Title"));
            string searchInput3 = GlobalDefinitions.driver.FindElement(By.XPath("//tbody//tr[1]//td[5]")).Text;

            Assert.AreEqual(searchInput3, ExcelLib.ReadData(3, "ServiceType"));
        }
        public static void AddNewProperties()
        {
            //finding the excle path for input
            Global.ExcelData.PopulateInCollection(CommonFeatures.ExcelPath, "Add Property");

            //To skip the alert
            GenericMethods.ButtonClick(myDriver, "XPath", "/html/body/div[5]/div/div[5]/a[1]");

            Thread.Sleep(1500);

            //loop for multiple properties getting added at single shot
            int loopNum = CommonFeatures.RowCount + 2;

            for (int rowNum = 2; rowNum < loopNum; rowNum++)
            {
                //navigate to Owners>Properties
                GenericMethods.ButtonClick(myDriver, "XPath", "/html/body/div[1]/div/div[2]/div[1]");
                GenericMethods.ButtonClick(myDriver, "XPath", "/html/body/div[1]/div/div[2]/div[1]/div/a[1]");

                //Checking the right page
                Assert.AreEqual("Properties | Property Community", myDriver.Title);
                //CommonFeatures.test.Log(RelevantCodes.ExtentReports.LogStatus.Info, "In My Properties page");

                //clicking add new properties
                Thread.Sleep(1000);
                GenericMethods.ButtonClick(myDriver, "XPath", "//body/div[2]/section/div/div/div[2]/div/div[2]/a[2]");

                // Adding property details
                GenericMethods.TextBox(myDriver, "XPath", "//body/div[2]/section/form/fieldset/div/div/div/input", Global.ExcelData.ReadData(rowNum, "PropertyName"));
                GenericMethods.CheckLength(4, 30, Global.ExcelData.ReadData(rowNum, "PropertyName"), "Property Name");

                GenericMethods.ButtonClick(myDriver, "XPath", "//fieldset/div/div[2]/div");
                GenericMethods.ButtonClick(myDriver, "XPath", "//fieldset/div/div[2]/div");
                GenericMethods.TextBox(myDriver, "XPath", "//body/div[2]/section/form/fieldset/div[3]/div/div[2]/div/div/input", Global.ExcelData.ReadData(rowNum, "Number"));
                GenericMethods.TextBox(myDriver, "XPath", "//body/div[2]/section/form/fieldset/div[3]/div/div[2]/div[2]/div/input", Global.ExcelData.ReadData(rowNum, "Street"));
                GenericMethods.TextBox(myDriver, "XPath", "//body/div[2]/section/form/fieldset/div[3]/div/div[3]/div/div[2]/div/input", Global.ExcelData.ReadData(rowNum, "City"));
                //postcode
                GenericMethods.TextBox(myDriver, "XPath", "//input[@placeholder='PostCode']", Global.ExcelData.ReadData(rowNum, "Postcode"));
                GenericMethods.ValidNumeric(Global.ExcelData.ReadData(rowNum, "Postcode"), "Postcode");

                //Region
                GenericMethods.TextBox(myDriver, "Id", "region", Global.ExcelData.ReadData(rowNum, "Region"));

                //year built
                GenericMethods.TextBox(myDriver, "XPath", "//input[@placeholder = 'Year Built']", Global.ExcelData.ReadData(rowNum, "Yearbuilt"));
                GenericMethods.ValidYear(1900, Global.ExcelData.ReadData(rowNum, "Yearbuilt"), "Year Built");

                //rent
                GenericMethods.TextBox(myDriver, "XPath", "//input[@placeholder='Rent Amount']", Global.ExcelData.ReadData(rowNum, "targetrent"));

                //bedroom , bathroom, carpark
                GenericMethods.TextBox(myDriver, "XPath", "//input[@placeholder='Number of Bedrooms']", Global.ExcelData.ReadData(rowNum, "bedroom"));
                GenericMethods.ValidNumeric(Global.ExcelData.ReadData(rowNum, "bedroom"), "Bedroom");
                GenericMethods.TextBox(myDriver, "XPath", "//input[@placeholder='Number of Bathrooms']", Global.ExcelData.ReadData(rowNum, "bathroom"));
                GenericMethods.ValidNumeric(Global.ExcelData.ReadData(rowNum, "bathroom"), "Bathroom");
                GenericMethods.TextBox(myDriver, "XPath", "//input[@placeholder='Number of car parks']", Global.ExcelData.ReadData(rowNum, "carpark"));
                GenericMethods.ValidNumeric(Global.ExcelData.ReadData(rowNum, "carpark"), "Carpark");

                //description of the property
                GenericMethods.TextBox(myDriver, "XPath", "//textarea[@class='add-prop-desc']", Global.ExcelData.ReadData(rowNum, "description"));
                GenericMethods.CheckLength(10, 100, Global.ExcelData.ReadData(rowNum, "description"), "Description");

                //picture of the property
                Thread.Sleep(2000);
                GenericMethods.TextBox(myDriver, "Id", "file-upload", CommonFeatures.PhotoPath);

                //navigating to financce page
                Thread.Sleep(2000);
                GenericMethods.ButtonClick(myDriver, "XPath", "//button[@class='ui teal button']");
                Assert.AreEqual("Properties | Add New Property", myDriver.Title);
                //CommonFeatures.test.Log(RelevantCodes.ExtentReports.LogStatus.Info,"In Finance Page");

                //entering details in finance page
                GenericMethods.TextBox(myDriver, "XPath", "//form/fieldset[2]/div/div/div/input", Global.ExcelData.ReadData(rowNum, "purchaseprice"));
                GenericMethods.TextBox(myDriver, "XPath", "//form/fieldset[2]/div/div[2]/div/input", Global.ExcelData.ReadData(rowNum, "mortgage"));
                GenericMethods.TextBox(myDriver, "XPath", "//form/fieldset[2]/div/div[3]/div/input", Global.ExcelData.ReadData(rowNum, "homevalue"));

                //navigating to tenant screen
                GenericMethods.ButtonClick(myDriver, "XPath", "//fieldset[2]/div[8]/button[3]");
                Assert.AreEqual("Properties | Add New Property", myDriver.Title);
                //CommonFeatures.test.Log(RelevantCodes.ExtentReports.LogStatus.Info,"In Tenant Page");

                //entering details in tenant page
                GenericMethods.TextBox(myDriver, "XPath", "//section/form/fieldset[3]/div/div/div/input", Global.ExcelData.ReadData(rowNum, "tenantmail"));
                GenericMethods.TextBox(myDriver, "Id", "fname", Global.ExcelData.ReadData(rowNum, "firstname"));
                GenericMethods.TextBox(myDriver, "Id", "lname", Global.ExcelData.ReadData(rowNum, "lastname"));
                GenericMethods.TextBox(myDriver, "Id", "ramount", Global.ExcelData.ReadData(rowNum, "rentamount"));

                GenericMethods.TextBox(myDriver, "Id", "sdate", Global.ExcelData.ReadData(rowNum, "sdate"));
                GenericMethods.TextBox(myDriver, "Id", "sdate", (Keys.Tab));
                GenericMethods.TextBox(myDriver, "Id", "sdate", "0105AM");

                GenericMethods.TextBox(myDriver, "Id", "edate", Global.ExcelData.ReadData(rowNum, "enddate"));
                GenericMethods.TextBox(myDriver, "Id", "edate", (Keys.Tab));
                GenericMethods.TextBox(myDriver, "Id", "edate", "0105AM");

                GenericMethods.TextBox(myDriver, "Id", "psdate", Global.ExcelData.ReadData(rowNum, "psdate"));
                GenericMethods.TextBox(myDriver, "Id", "psdate", (Keys.Tab));
                GenericMethods.TextBox(myDriver, "Id", "psdate", "0105AM");

                //save property
                GenericMethods.ButtonClick(myDriver, "Id", "saveProperty");
                //Verification
                Thread.Sleep(500);
                Assert.AreEqual("Properties | Add New Property", Global.GlobalDriver.driver.Title);
                CommonFeatures.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Property Added Successfully");
            }
        }
        public void EnterShareSkill()
        {
            GlobalDefinitions.Wait();
            ShareSkillButton.Click();
            //Checking the right page
            Assert.AreEqual("ServiceListing", GlobalDefinitions.driver.Title);
            Base.test = Base.extent.StartTest("On Share Skill page");
            //Populate the Excel Sheet
            Global.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill");
            //Enter TITLE
            Title.SendKeys(ExcelLib.ReadData(2, "Title"));
            //Check Length of Title
            GenericMethods.CheckLength(4, 100, ExcelLib.ReadData(2, "Title"), "Title");
            //Enter Description
            Description.SendKeys(ExcelLib.ReadData(2, "Description"));
            GenericMethods.CheckLength(4, 600, ExcelLib.ReadData(2, "Description"), "Description");
            //Select Category form dropdown
            CategoryDropDown.SendKeys(ExcelLib.ReadData(2, "Category"));
            SubCategoryDropDown.SendKeys(ExcelLib.ReadData(2, "SubCategory"));
            //Enter tag
            TxtTags.SendKeys(ExcelLib.ReadData(2, "Tags"));
            TxtTags.SendKeys(Keys.Enter);
            //Select service Type
            IWebElement ServiceTypeOptions = GlobalDefinitions.driver.FindElement(By.XPath("//form/div[5]/div[@class='twelve wide column']/div/div[@class='field']"));

            ServiceTypeOptions.Click();
            //Select Location Type
            IWebElement LocationTypeOption = GlobalDefinitions.driver.FindElement(By.XPath("//div[6]//div[2]//div[1]//div[1]//div[1]//input[1]"));

            LocationTypeOption.Click();
            //Enter start Date and End date
            StartDateDropDown.SendKeys(ExcelLib.ReadData(2, "Startdate"));
            EndDateDropDown.SendKeys(ExcelLib.ReadData(2, "Enddate"));
            // Loop for no. of days available,Start time and End time
            for (int i = 2; i < 9; i++)
            {
                for (int j = 2; j < 9; j++)
                {
                    IWebElement StartTime = GlobalDefinitions.driver.FindElement(By.XPath("//div[" + i + "]/div[2]/input"));
                    IWebElement EndTime   = GlobalDefinitions.driver.FindElement(By.XPath("//div[" + j + "]/div[3]/input"));
                    if (i == 2 && j == 2)
                    {
                        GlobalDefinitions.driver.FindElement(By.XPath("//div[contains(@class,'twelve wide column')]//div[2]//div[1]//div[1]//input[1]")).Click();
                        StartTime.SendKeys("0230PM");
                        StartTime.SendKeys(Keys.Tab);
                        EndTime.SendKeys("3052PM");
                    }
                    if (i == 3 && j == 3)
                    {
                        GlobalDefinitions.driver.FindElement(By.XPath("//div[3]//div[1]//div[1]//input[1]")).Click();
                        StartTime.SendKeys("0530PM");
                        EndTime.SendKeys("0856PM");
                    }
                }
            }
            // Select Skill Trade
            IWebElement credit = GlobalDefinitions.driver.FindElement(By.XPath("//div[8]//div[2]//div[1]//div[2]//div[1]//input[1]"));

            //Checking if the radio is selected or not
            if (!SkillTradeOption.Selected)
            {
                SkillTradeOption.Click();
            }
            Boolean status = GlobalDefinitions.driver.FindElement(By.XPath("//input[@type='radio']")).Selected;

            //To Check Radiobutton is selected or not
            if (status)
            {
                Console.WriteLine("RadioButton is checked");
            }
            else
            {
                Console.WriteLine("RadioButton is unchecked");
            }
            //Enter SkillExchange
            SkillExchange.SendKeys(ExcelLib.ReadData(2, "Skill-Exchange"));
            SkillExchange.SendKeys(Keys.Enter);
            //Upload File Using Auto IT
            WorkSample.Click();

            AutoItX3 autoIt = new AutoItX3();

            autoIt.WinWait("Open", "File Upload", 1);

            autoIt.WinActivate("Open", "File Upload");


            autoIt.ControlFocus("Open", "File Upload", "[CLASS:Edit; INSTANCE:1]");

            autoIt.Send(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..")) + "\\Test.txt");
            autoIt.Sleep(1000);
            autoIt.Send("{ENTER}");
            //	autoIt.Sleep(1000);
            //Select Active Type
            IWebElement ActiveOption = GlobalDefinitions.driver.FindElement(By.XPath("//form/div[10]/div[@class='twelve wide column']/div/div[@class = 'field']"));

            ActiveOption.Click();
            GlobalDefinitions.Wait();
            Save.Click();
            GlobalDefinitions.Wait();

            Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Skills Added Successfully");
            //Assert.AreEqual("ServiceListing", GlobalDefinitions.driver.Title);

            //Assert on category / title / Service Type after adding the skill and displayed on Manage Listing Page
            string searchInput1 = GlobalDefinitions.driver.FindElement(By.XPath("//td[contains(text(),'Programming & Tech')]")).Text;

            Console.WriteLine(searchInput1);
            Assert.AreEqual(searchInput1, ExcelLib.ReadData(2, "Category"));

            string searchInput2 = GlobalDefinitions.driver.FindElement(By.XPath("//table[@class='ui striped table']//tbody//tr[1]//td[3]")).Text;

            Console.WriteLine(searchInput2);
            Assert.AreEqual(searchInput2, ExcelLib.ReadData(2, "Title").TrimEnd());

            //string searchInput3 = GlobalDefinitions.driver.FindElement(By.XPath("//table[@class='ui striped table']//tbody//tr[1]//td[5]")).Text;
            //Assert.AreEqual(searchInput3, ExcelLib.ReadData(2, "ServiceType"));
        }