Exemplo n.º 1
0
        public IList <CruiseData> getCruiseData(IList <IWebElement> clearedList)
        {
            IList <CruiseData> cruiseDataList = new List <CruiseData>();

            foreach (IWebElement element in clearedList)
            {
                CruiseData cd = new CruiseData();
                cd.cruise = element.FindElement(By.CssSelector("a > span > span.details-body > h4")).Text;

                try
                {
                    cd.price = element.FindElement(By.CssSelector("[class='cruiseOnly price']")).Text;
                }
                catch
                {
                    cd.price = element.FindElement(By.CssSelector("[class='fully-booked']")).Text;
                }

                cd.ship = element.FindElement(By.CssSelector("[class='ship']")).Text;

                cruiseDataList.Add(cd);
            }

            return(cruiseDataList);
        }
        public static IList <CruiseData> getCruisedataFromExcel()
        {
            IList <CruiseData> cruisedataList = new List <CruiseData>();

            XLS.XLWorkbook workbook  = new XLS.XLWorkbook(@"C:\Users\fleet\Documents\cruises.xlsx");
            var            worksheet = workbook.Worksheet(1);
            var            usedRange = worksheet.RangeUsed();

            for (int i = 1; i <= usedRange.RowCount(); i++)
            {
                CruiseData cs = new CruiseData();
                cs.cruise = worksheet.Row(i).Cell(1).GetValue <String>();
                cs.ship   = worksheet.Row(i).Cell(2).GetValue <String>();
                cs.price  = worksheet.Row(i).Cell(3).GetValue <String>();
                cruisedataList.Add(cs);
            }
            workbook.Dispose();
            return(cruisedataList);
        }