Advertisement
Guest User

Light Clients flow

a guest
Nov 29th, 2017
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.55 KB | None | 0 0
  1. using AQA.LightClient.Helpers;
  2. using NUnit.Framework;
  3. using OpenQA.Selenium;
  4. using OpenQA.Selenium.Chrome;
  5. using OpenQA.Selenium.Interactions;
  6. using OpenQA.Selenium.Support.UI;
  7. using System;
  8.  
  9. namespace AQA
  10. {
  11.     public class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             //// TODO: Extract as a separate class to TestScenarios
  16.             var base_url = "https://tst-04-pfp.test.intelliflo.com/planningandadvice";
  17.             IWebDriver driver = new ChromeDriver();
  18.             String nextButtonXpath = "//a[@title='Next']";
  19.  
  20.             var helper = new LoginHelper();
  21.  
  22.             driver.Manage().Window.Maximize();
  23.             driver.Navigate().GoToUrl(base_url);
  24.  
  25.             WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
  26.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//b[contains(text(), 'Looking for a quick, simple investment? Start here')]")));
  27.  
  28.             IWebElement start_planning_button = driver.FindElement(By.XPath("//button[@id='btnStartPlanning']"));
  29.             Assert.IsFalse(start_planning_button.Enabled);
  30.  
  31.  
  32.             // Scrolling down the page so that the 2 checkboxes are visible and can be clicked
  33.             var pageFooter = driver.FindElement(By.XPath("//footer"));
  34.             Actions actions = new Actions(driver);
  35.             actions.MoveToElement(pageFooter);
  36.             actions.Perform();
  37.  
  38.  
  39.             // locating terms of service checkbox
  40.             IWebElement terms_of_service_checkbox = driver.FindElement(By.XPath("//span[contains(text(), 'Having read')]"));
  41.            
  42.  
  43.             Actions clicker = new Actions(driver);
  44.             clicker.MoveToElement(terms_of_service_checkbox, 0, 0).Click().Perform();
  45.            
  46.  
  47.             // locating "no liabilities or debts" checkbox
  48.             IWebElement has_no_debts_checkbox = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//span[contains(text(), 'I confirm I do not')]")));
  49.             has_no_debts_checkbox.Click();
  50.  
  51.             start_planning_button.Click();
  52.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//b[contains(text(), 'New Client?')]"))); // Waiting till the popup loads
  53.  
  54.  
  55.             //helper.LinkedInLogin(driver, wait, "darryl.snyder@bk.ru", "P@ssw0rd12"); // Signing up with linkedin
  56.             helper.FacebookLogin(driver, wait, "gregg.walton@mail.ru", "qWaszx12"); // Signing up with linkedin
  57.  
  58.  
  59.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//b[contains(text(), 'How the service works')]")));
  60.             IWebElement nextButton = driver.FindElement(By.XPath(nextButtonXpath));
  61.             nextButton.Submit();
  62.  
  63.  
  64.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//b[contains(text(), 'Your investment Choices')]")));
  65.             IWebElement goalTravel = driver.FindElement(By.XPath("//i[@class='icon-list-category-holiday']"));
  66.             goalTravel.Click();
  67.             nextButton = driver.FindElement(By.XPath(nextButtonXpath));
  68.             nextButton.Submit();
  69.  
  70.  
  71.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//b[contains(text(), 'About your attitude to investment risk')]")));
  72.             nextButton = driver.FindElement(By.XPath(nextButtonXpath));
  73.             nextButton.Submit();
  74.  
  75.  
  76.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//b[contains(text(), 'Risk tolerance questions')]")));
  77.             var atrAnswersXpath = "//button[@id='question_{0}_answer_5']";
  78.  
  79.  
  80.             for (int i = 0; i <= 9; i++)
  81.             {
  82.                 string str = string.Format(atrAnswersXpath, i);
  83.                 wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(str)));
  84.                 driver.FindElement(By.XPath(str)).Click();                
  85.             }
  86.  
  87.  
  88.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//b[contains(text(), 'Your risk tolerance profile')]")));
  89.             nextButton = driver.FindElement(By.XPath(nextButtonXpath));
  90.             nextButton.Submit();
  91.  
  92.  
  93.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//b[contains(text(), 'Your investment projection')]")));
  94.             nextButton = driver.FindElement(By.XPath(nextButtonXpath));
  95.             nextButton.Submit();
  96.  
  97.  
  98.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//b[contains(text(), 'About your risk capacity')]")));
  99.             nextButton = driver.FindElement(By.XPath(nextButtonXpath));
  100.             nextButton.Submit();
  101.  
  102.  
  103.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//b[contains(text(), 'Risk capacity questions')]")));
  104.        
  105.  
  106.  
  107.             var cflAnswersXpath = "//button[@type='button' and @id='question_{0}_answer_2']";
  108.  
  109.  
  110.             for (int i = 0; i <= 2; i++)
  111.             {
  112.                 string str = string.Format(cflAnswersXpath, i);
  113.                 wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(str)));
  114.                 driver.FindElement(By.XPath(str)).Click();
  115.             }
  116.  
  117.  
  118.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//b[contains(text(), 'Your proposed risk category')]")));
  119.             String recommendedRiskCategory = "We recommend risk category 3";
  120.             Assert.AreEqual(driver.FindElement(By.XPath("//table[@class='comparison table']//th[3]")).Text, recommendedRiskCategory);
  121.  
  122.  
  123.             nextButton = driver.FindElement(By.XPath(nextButtonXpath));
  124.             nextButton.Submit();
  125.  
  126.  
  127.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//b[contains(text(), 'Please confirm your investment choices')]")));
  128.             nextButton = driver.FindElement(By.XPath(nextButtonXpath));
  129.             nextButton.Submit();
  130.  
  131.  
  132.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//b[contains(text(), 'Our recommendation for you')]")));
  133.             IWebElement continueNowButton = driver.FindElement(By.XPath("//a[@title='Continue now']"));
  134.             continueNowButton.Submit();
  135.  
  136.  
  137.             IWebElement emailAddress = wait.Until(ExpectedConditions.ElementIsVisible((By.XPath("//input[@id='pers-det-email']"))));
  138.  
  139.             // new object of Select class created in order to do manipulations with drop-down lists
  140.             //Confirm your details page
  141.             SelectElement title = new SelectElement(driver.FindElement(By.XPath("//select[@id='pers-det-title']")));
  142.             title.SelectByValue("Mr");
  143.  
  144.             SelectElement dayOfBirth = new SelectElement(driver.FindElement(By.XPath("//select[@id='pers-det-dob-day']")));
  145.             dayOfBirth.SelectByValue("14");
  146.            
  147.             SelectElement monthOfBirth = new SelectElement(driver.FindElement(By.XPath("//select[@id='pers-det-dob-month']")));
  148.             monthOfBirth.SelectByValue("9");
  149.  
  150.             SelectElement yearOfBirth = new SelectElement(driver.FindElement(By.XPath("//select[@id='pers-det-dob-year']")));
  151.             yearOfBirth.SelectByValue("1984");
  152.  
  153.  
  154.             IWebElement contactNumberInput = driver.FindElement(By.XPath("//input[@id='pers-det-contact']"));
  155.             contactNumberInput.SendKeys("+44 207 111 7755");
  156.  
  157.  
  158.             IWebElement residencyCheckbox = driver.FindElement(By.XPath("//label[@for='pers-isUKResident']/span"));
  159.             residencyCheckbox.Click();
  160.  
  161.    
  162.             IWebElement citizenshipCheckbox = driver.FindElement(By.XPath("//label[@for='pers-isNotUSCitizen']/span"));
  163.             citizenshipCheckbox.Click();
  164.  
  165.             IWebElement addressLineOneInput = driver.FindElement(By.XPath("//input[@id='pers-addr-line1']"));
  166.             addressLineOneInput.SendKeys("Address Line 1");
  167.  
  168.             IWebElement townInput = driver.FindElement(By.XPath("//input[@id='pers-addr-locality']"));
  169.             townInput.SendKeys("Kingston");
  170.  
  171.             IWebElement postalCodeInput = driver.FindElement(By.XPath("//input[@id='pers-addr-postalcode']"));
  172.             postalCodeInput.SendKeys("KT1 2PD");
  173.  
  174.             IWebElement nationalInsuranceNumberInput = driver.FindElement(By.XPath("//input[@id='pers-NINumber']"));
  175.             nationalInsuranceNumberInput.SendKeys("AA018998B");
  176.  
  177.             nextButton = driver.FindElement(By.XPath(nextButtonXpath));
  178.             nextButton.Submit();
  179.  
  180.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//b[contains(text(), 'Declaration')]")));
  181.            
  182.             // Go to PFP Profile
  183.             driver.Navigate().GoToUrl("https://tst-04-pfp.test.intelliflo.com/profile");
  184.  
  185.             // Verify the client was converted and his email address can be found in his PFP Profile
  186.             wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@id='personal-details']/div[2]/div/section[1]/div/div[2]/div[2]/div")));
  187.             Assert.AreEqual(driver.FindElement(By.XPath("//*[@id='personal-details']/div[2]/div/section[1]/div/div[2]/div[2]/div")).Text, "gregg.walton@mail.ru");
  188.  
  189.  
  190.             // Logout from PFP
  191.             driver.FindElement(By.XPath("//a[@title='Logout']")).Click();
  192.  
  193.  
  194.             driver.Navigate().GoToUrl("https://tst-04.test.intelliflo.com/nio/dashboard/userdashboard");
  195.             wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//span[contains(text(), 'Login')]"))).Click();
  196.  
  197.             // Log into iO
  198.             IWebElement usernameInput = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id='username']")));
  199.             usernameInput.SendKeys("MK04");
  200.  
  201.             IWebElement passwordInput = driver.FindElement(By.XPath("//input[@id='password']"));
  202.             passwordInput.SendKeys("qWaszx12");
  203.  
  204.             IWebElement loginButton = driver.FindElement(By.XPath("//button[contains(text(), 'Login')]"));
  205.             loginButton.Click();
  206.  
  207.  
  208.             // Verification whether the client was registered to iO
  209.  
  210.             IWebElement myRecentClientsLInk = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//a[contains(text(), 'My Recent Clients')]")));
  211.             myRecentClientsLInk.Click();
  212.  
  213.             IWebElement emailAddressInput = driver.FindElement(By.XPath("//input[@id='id_Plan_EmailAddress']"));
  214.             emailAddressInput.SendKeys("gregg.walton@mail.ru");
  215.  
  216.             IWebElement searchButton = driver.FindElement(By.XPath("//a[starts-with(text(), 'Search')]"));
  217.             searchButton.Click();
  218.  
  219.             IWebElement searchResultsLabel = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[contains(text(), 'Search Results')]")));
  220.  
  221.             Assert.IsTrue(driver.FindElement(By.XPath("//tr[starts-with(@id, 'ClientSearchNameGrid')]/td[11]/span")).Text.Length > 0);
  222.  
  223.          
  224.             driver.Quit();
  225.  
  226.  
  227.         }
  228.     }
  229. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement