public void GetWebElement()
        {
            var sel         = new Selenium();
            var findelement = new object();
            var webelement  = sel.GetWebElement(1, "1", "");

            findelement = By.CssSelector("1");

            Assert.AreEqual(findelement, webelement);
        }
示例#2
0
        internal List <OpenBookPositionData> GetOpenBookPositionData(RemoteWebDriver driver, int tableRowweguiMapId)
        {
            try
            {
                var          sl                       = new Selenium();
                TestFlowInfo tfi                      = new TestFlowInfo(true, "OpenBookValidator");
                var          dataAccess               = new DataAccessor(true, ref tfi);
                var          guimapadapter            = new GuiMapTableAdapter();
                string       userNameElementValue     = guimapadapter.GetTagTypeValue(Constants.ObOpenTradesUserName);
                string       userName                 = driver.FindElement((By)sl.GetWebElement(1, userNameElementValue, string.Empty)).Text;
                string       userTableRowElementValue = guimapadapter.GetTagTypeValue(tableRowweguiMapId);
                ReadOnlyCollection <IWebElement> rows =
                    driver.FindElements((By)sl.GetWebElement(1, userTableRowElementValue, string.Empty));
                var openbookpositiondata = new List <OpenBookPositionData>();
                foreach (IWebElement row in rows)
                {
                    StockStatus?stockStatus = StockStatus.Position;
                    string      parentUserNameElementValue =
                        guimapadapter.GetTagTypeValue(Constants.ObOpenTardesParentNameGuiMapId);
                    string parentUserName =
                        row.FindElement((By)sl.GetWebElement(1, parentUserNameElementValue, string.Empty)).Text;
                    string initRateStringElementValue =
                        guimapadapter.GetTagTypeValue(Constants.ObOpenTardesInitRateStringGuimapid);
                    string initRateString =
                        row.FindElement((By)sl.GetWebElement(1, initRateStringElementValue, string.Empty)).Text;
                    decimal initRate;

                    if (initRateString != string.Empty)
                    {
                        String trimmedRate = sl.GetCleanRate(initRateString);
                        initRate = Convert.ToDecimal(trimmedRate);
                    }
                    else
                    {
                        initRate = 0;
                    }
                    string instrumentDisplayNameElementValue =
                        guimapadapter.GetTagTypeValue(Constants.ObOpenTradedInstrumentDisplayName);
                    string instrumentDisplayName =
                        row.FindElement((By)sl.GetWebElement(1, instrumentDisplayNameElementValue, string.Empty))
                        .Text.Replace("/", "");
                    string isBuyStringElementValue = guimapadapter.GetTagTypeValue(Constants.ObOpenTradesIsBuyString);
                    string isBuyString             =
                        row.FindElement((By)sl.GetWebElement(1, isBuyStringElementValue, string.Empty)).Text;
                    bool isBuy;
                    if (String.Compare(isBuyString, "BUY", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        isBuy = true;
                    }
                    else
                    {
                        isBuy = false;
                    }
                    string isOverWeekendNameElementValue =
                        guimapadapter.GetTagTypeValue(Constants.ObOpenTradesIsOverWeekendNonStocks);
                    bool isOverWeekend = sl.CheckIfElementFind(row,
                                                               (By)sl.GetWebElement(1, isOverWeekendNameElementValue, string.Empty),
                                                               driver);
                    if (isOverWeekend == false)
                    {
                        //non stocks
                        isOverWeekendNameElementValue =
                            guimapadapter.GetTagTypeValue(Constants.ObOpenTradesIsOverWeekendStocks);
                        isOverWeekend = sl.CheckIfElementFind(row, (By)sl.GetWebElement(1, isOverWeekendNameElementValue, string.Empty), driver);
                    }

                    decimal limitRate;
                    string  limitRateElementValue = guimapadapter.GetTagTypeValue(Constants.ObOpenTradesLimitRate);
                    if (sl.CheckIfElementFind(row, (By)sl.GetWebElement(1, limitRateElementValue, string.Empty), driver))
                    {
                        string limitRateString =
                            row.FindElement((By)sl.GetWebElement(1, limitRateElementValue, string.Empty)).Text;
                        Char[] limitRatearr =
                            limitRateString.ToCharArray().Where(c => Char.IsDigit(c) || Char.IsPunctuation(c)).ToArray();
                        limitRate = Convert.ToDecimal(new string(limitRatearr));

                        stockStatus = new StockStatus(); //non stock
                    }
                    else
                    {
                        limitRate = 999999.9m;
                    }
                    decimal stopRate;
                    string  stopRateElementValue = guimapadapter.GetTagTypeValue(Constants.ObOpenTradeStopRate);
                    if (sl.CheckIfElementFind(row, (By)sl.GetWebElement(1, stopRateElementValue, string.Empty),
                                              driver))
                    {
                        string stopRateString =
                            row.FindElement((By)sl.GetWebElement(1, stopRateElementValue, string.Empty)).Text;
                        Char[] stopRatearr =
                            stopRateString.ToCharArray().Where(c => Char.IsDigit(c) || Char.IsPunctuation(c)).ToArray();
                        stopRate = Convert.ToDecimal(new string(stopRatearr));
                    }
                    else
                    {
                        stopRate = 0;
                    }


                    string instrumentElementValue = guimapadapter.GetTagTypeValue(Constants.ObOpenTradesInstrument);
                    int    positionId             =
                        Convert.ToInt32(
                            row.FindElement((By)sl.GetWebElement(1, instrumentElementValue, string.Empty))
                            .GetAttribute("positionid"));

                    string infoRowPendingElementValue =
                        guimapadapter.GetTagTypeValue(Constants.ObOpenTaredsInfoRowPending);
                    bool isInfoRowPending = sl.CheckIfElementFind(row,
                                                                  (By)
                                                                  sl.GetWebElement(1, infoRowPendingElementValue, string.Empty),
                                                                  driver);
                    if (isInfoRowPending)
                    {
                        stockStatus = StockStatus.Order;
                    }

                    try
                    {
                        openbookpositiondata.Add(new OpenBookPositionData(userName, parentUserName, initRate, instrumentDisplayName, isBuy, isOverWeekend, limitRate, stopRate, positionId, stockStatus));
                    }
                    catch (Exception e)
                    {
                        Logger.Error("Can't Add + " + instrumentDisplayName + " to openbook position data" + e.Message);
                    }
                }
                return(openbookpositiondata);
            }
            catch (Exception)
            {
                return(null);
            }
        }