Exemple #1
0
        public static void VerifyTokenCanbeBorrowedFromLiquidityPool()
        {
            try
            {
                Console.WriteLine("Login to the app...");
                ReadOnlyCollection <string> windows = MainPageBb.LoginToMainPage("borrower");
                string MetamaskTab  = windows[0];
                string BloqboardTab = windows[1];

                Console.WriteLine("Test started...");
                IWebElement Borrow = Browser.CurrentBrowser.FindElement(By.CssSelector("div.sidebar-block.loans-block > a:nth-of-type(1)"));
                Borrow.Click();
                Browser.LongPause();

                string environment = TestData.DefineEnvironmentDependingOnEnvironment();
                if (environment.Contains("STAGING"))
                {
                    IWebElement MyLoans = Browser.CurrentBrowser.FindElement(By.CssSelector("div > div:nth-of-type(2) > a:nth-of-type(2)"));
                    MyLoans.Click();
                    Browser.LongPause();
                    string loanedcountSTAGING = "";

                    IList <IWebElement> elementListRowsSTAGING = Browser.CurrentBrowser.FindElements(By.CssSelector(".on-demand-wrapper .content-table-row"));
                    foreach (var el in elementListRowsSTAGING)
                    {
                        var children  = el.FindElements(By.XPath(".//*"));
                        var tokenName = children[0].Text;
                        int i         = 1;
                        if (tokenName.Contains("ZRX"))
                        {
                            foreach (var ele in children)
                            {
                                if (ele.Text.Contains("Borrowed") && loanedcountSTAGING == "")
                                {
                                    loanedcountSTAGING = ele.Text;
                                }
                            }
                        }
                    }

                    Browser.CurrentBrowser.Navigate().GoToUrl(TestData.Urls.Lend);
                    Browser.LongPause();

                    IList <IWebElement> elementListRowsBorrow = Browser.CurrentBrowser.FindElements(By.CssSelector(".on-demand-wrapper .content-table-row"));
                    foreach (var el in elementListRowsBorrow)
                    {
                        var children  = el.FindElements(By.XPath(".//*"));
                        var tokenName = children[0].Text;
                        int i         = 1;
                        if (tokenName.Contains("ZRX"))
                        {
                            foreach (var ele in children)
                            {
                                if (ele.Text.Contains("BORROW") && ele.TagName == "div")
                                {
                                    i++;

                                    if (i >= 3)
                                    {
                                        ele.Click();
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    Browser.ShortPause();
                    IWebElement amountBorrow = Browser.CurrentBrowser.FindElement(LendAMountImput);
                    amountBorrow.SendKeys("0.0001");
                    Browser.MiddlePause();
                    IWebElement confirmBorrow = Browser.CurrentBrowser.FindElement(By.CssSelector("button.on-demand-modal__button.btn-green"));
                    confirmBorrow.Click();
                    Browser.LongPause();

                    Console.WriteLine("Approve on MetaMask...");
                    Wallets.ApproveTransaction(MetamaskTab, BloqboardTab);
                    Browser.LongPause();

                    Console.WriteLine("Do the final assert...");
                    IWebElement Close = Browser.CurrentBrowser.FindElement(By.CssSelector("button.main-btn"));
                    Close.Click();
                    Browser.ShortPause();

                    //IWebElement MyLoansAfter = Browser.CurrentBrowser.FindElement(By.CssSelector("div > div:nth-of-type(2) > a:nth-of-type(2)"));
                    //MyLoansAfter.Click();
                    //Browser.LongPause();
                    //string loanedAmountAfterBorrow = loanedcountSTAGING;
                    //var loanedAfterStaging = CheckBorrowedAmount();
                    //Assert.IsTrue(loanedcountSTAGING != loanedAfterStaging, "[" + Env + "] BLOQBOARD", "Lend functionality is not working as expected");
                }
                else
                {
                    string loanedcount = "";

                    IList <IWebElement> elementListRows = Browser.CurrentBrowser.FindElements(By.CssSelector(".on-demand-wrapper .content-table-row"));
                    foreach (var el in elementListRows)
                    {
                        var children  = el.FindElements(By.XPath(".//*"));
                        var tokenName = children[0].Text;
                        int i         = 1;
                        if (tokenName.Contains("ZRX"))
                        {
                            foreach (var ele in children)
                            {
                                if (ele.Text.Contains("Borrowed") && loanedcount == "")
                                {
                                    loanedcount = ele.Text;
                                }

                                if (ele.Text.Contains("BORROW") && ele.TagName == "div")
                                {
                                    i++;

                                    if (i >= 3)
                                    {
                                        ele.Click();
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    Browser.ShortPause();
                    IWebElement amount = Browser.CurrentBrowser.FindElement(LendAMountImput);
                    amount.SendKeys("0.0001");
                    Browser.MiddlePause();
                    IWebElement confirm = Browser.CurrentBrowser.FindElement(By.CssSelector("button.on-demand-modal__button.btn-green"));
                    confirm.Click();

                    Console.WriteLine("Approve on MetaMask...");
                    Wallets.ApproveTransaction(MetamaskTab, BloqboardTab);

                    Console.WriteLine("Do the final assert...");
                    string loanedAmountAfter = loanedcount;
                    var    loanedAfter       = CheckBorrowedAmount();
                    //Assert.IsTrue(loanedcount != loanedAfter, "[" + Env + "] BLOQBOARD", "Lend functionality is not working as expected");
                }
            }
            catch (Exception exception)
            {
                Browser.Close();
                Assert.FinilizeErrors(Env, "BLOQBOARD", exception, false);
            }
        }
Exemple #2
0
        public static void VerifyTokenCanbeLendedtoLiquidityPool()
        {
            try
            {
                Console.WriteLine("Login to the app...");
                ReadOnlyCollection <string> windows = MainPageBb.LoginToMainPage("lender");
                string MetamaskTab  = windows[0];
                string BloqboardTab = windows[1];

                Console.WriteLine("Test started...");
                IWebElement MyLoans = Browser.CurrentBrowser.FindElement(By.CssSelector("div > div:nth-of-type(2) > a:nth-of-type(2)"));
                MyLoans.Click();
                Browser.LongPause();

                string loanedcount = CheckLoanedAmount();
                Browser.MiddlePause();

                Browser.CurrentBrowser.Navigate().GoToUrl(TestData.DefineRootAdressDependingOnEnvironment() + "lend");
                Browser.LongPause();
                IList <IWebElement> elementListRows = Browser.CurrentBrowser.FindElements(By.CssSelector(".on-demand-wrapper .content-table-row"));
                foreach (var el in elementListRows)
                {
                    var children  = el.FindElements(By.XPath(".//*"));
                    var tokenName = children[0].Text;
                    int i         = 1;
                    if (tokenName.Contains("WETH"))
                    {
                        foreach (var ele in children)
                        {
                            if (ele.Text.Contains("LEND") && ele.TagName == "div")
                            {
                                i++;

                                if (i >= 3)
                                {
                                    ele.Click();
                                    break;
                                }
                            }
                        }
                    }
                }

                Browser.ShortPause();
                IWebElement amount = Browser.CurrentBrowser.FindElement(LendAMountImput);
                amount.SendKeys("0.0001");
                Browser.MiddlePause();
                IWebElement confirm = Browser.CurrentBrowser.FindElement(ConfirmLendRedButton);
                confirm.Click();

                Console.WriteLine("Approve on MetaMask...");
                Wallets.ApproveTransaction(MetamaskTab, BloqboardTab);
                Browser.LongPause();

                Console.WriteLine("Do the final assert...");
                IWebElement Close = Browser.CurrentBrowser.FindElement(By.CssSelector("button.main-btn"));
                Close.Click();
                Browser.ShortPause();

                IWebElement MyLoansAfter = Browser.CurrentBrowser.FindElement(By.CssSelector("div > div:nth-of-type(2) > a:nth-of-type(2)"));
                MyLoansAfter.Click();
                Browser.LongPause();

                var loanedAfter = CheckLoanedAmount();
                //Assert.IsTrue(loanedcount != loanedAfter, "[" + Env + "] BLOQBOARD", "Lend functionality is not working as expected");
            }

            catch (Exception exception)
            {
                Browser.Close();
                string Environment = TestData.DefineEnvironmentDependingOnEnvironment();
                if (Environment.Contains("STAGING_Mainnet"))
                {
                    throw new Exception("Transaction wait is too long (more than 3 minutes)...");
                }

                Assert.FinilizeErrors(Env, "BLOQBOARD", exception, false);
            }
        }