Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.49 KB | None | 0 0
  1. package pages;
  2.  
  3. import java.util.List;
  4.  
  5. import org.openqa.selenium.By;
  6. import org.openqa.selenium.WebDriver;
  7. import org.openqa.selenium.WebElement;
  8. import org.openqa.selenium.remote.RemoteWebDriver;
  9.  
  10. import com.relevantcodes.extentreports.ExtentTest;
  11.  
  12. import wrappers.ProjectWrappers;
  13.  
  14. public class CreateIOIPage extends ProjectWrappers{
  15.  
  16. public CreateIOIPage(RemoteWebDriver driver, ExtentTest test){
  17. this.driver = driver;
  18. this.test = test;
  19.  
  20. if(!verifyTitle("DBVX",driver)){
  21. reportStep("This is not Home Page", "FAIL",driver);
  22. }
  23. }
  24.  
  25. public CreateIOIPage clickCCYDropdown(RemoteWebDriver driver) throws InterruptedException{
  26. clickByXpath(prop.getProperty("Home.CCY.Xpath"),driver);
  27. Thread.sleep(3000);
  28. return this;
  29.  
  30. }
  31.  
  32. public CreateIOIPage enterCCY(String data,RemoteWebDriver driver) {
  33. mouseOverEnterByXpath(prop.getProperty("Home.EnterCCY.Xpath"), data,driver);
  34. return this;
  35.  
  36. }
  37.  
  38. public CreateIOIPage enterAmount(String data,RemoteWebDriver driver) {
  39. enterByXpath(prop.getProperty("Home.Amount.Xpath"), data,driver);
  40. return this;
  41.  
  42. }
  43.  
  44. public CreateIOIPage clickAccDropdown(RemoteWebDriver driver) throws InterruptedException{
  45. clickByXpath(prop.getProperty("Home.Account.Xpath"),driver);
  46. Thread.sleep(3000);
  47. return this;
  48.  
  49. }
  50.  
  51.  
  52. public CreateIOIPage enterAccDropdown(String data,RemoteWebDriver driver) {
  53. mouseOverEnterByXpath(prop.getProperty("Home.EnterAccount.Xpath"), data,driver);
  54. return this;
  55.  
  56. }
  57.  
  58. public CreateIOIPage clickMaturityDropdown(RemoteWebDriver driver) throws InterruptedException{
  59. clickByXpath(prop.getProperty("Home.Maturity.Xpath"),driver);
  60. Thread.sleep(3000);
  61. return this;
  62.  
  63. }
  64. public CreateIOIPage clickExpandDropdown(RemoteWebDriver driver) throws InterruptedException{
  65. clickByXpath(prop.getProperty("Home.Tenor.Xpath"),driver);
  66. Thread.sleep(3000);
  67. return this;
  68.  
  69. }
  70. public CreateIOIPage clickTenorDate(String data,RemoteWebDriver driver) throws InterruptedException{
  71. clickByXpath("//div[text()='"+data+"']",driver);
  72. Thread.sleep(3000);
  73. return this;
  74.  
  75. }
  76.  
  77. public CreateIOIPage clickSettleDropdown(RemoteWebDriver driver) throws InterruptedException{
  78. clickByXpath(prop.getProperty("Home.Settle.Xpath"),driver);
  79. Thread.sleep(3000);
  80. return this;
  81.  
  82. }
  83.  
  84.  
  85. public CreateIOIPage enterSettleDropdown(String data,RemoteWebDriver driver) {
  86. mouseOverEnterByXpath(prop.getProperty("Home.Settle.Xpath"), data,driver);
  87. return this;
  88.  
  89. }
  90.  
  91.  
  92. public CreateIOIPage clickProductDropdown(RemoteWebDriver driver) throws InterruptedException{
  93. clickByXpath(prop.getProperty("Home.Product.Xpath"),driver);
  94. Thread.sleep(3000);
  95. return this;
  96.  
  97. }
  98.  
  99.  
  100. public CreateIOIPage enterProductDropdown(String data,RemoteWebDriver driver) {
  101. mouseOverEnterByXpath(prop.getProperty("Home.EnterProduct.Xpath"), data,driver);
  102. return this;
  103.  
  104. }
  105.  
  106.  
  107. public CreateIOIPage clickRateDropdown(RemoteWebDriver driver) throws InterruptedException{
  108. clickByXpath(prop.getProperty("Home.Rate.Xpath"),driver);
  109. Thread.sleep(3000);
  110. return this;
  111.  
  112. }
  113.  
  114.  
  115. public CreateIOIPage enterRateDropdown(String data,RemoteWebDriver driver) throws InterruptedException {
  116. mouseOverEnterByXpath(prop.getProperty("Home.EnterRate.Xpath"), data,driver);
  117. Thread.sleep(3000);
  118. return this;
  119.  
  120. }
  121.  
  122. public CreateIOIPage clickInvestButton(RemoteWebDriver driver) throws InterruptedException{
  123. clickByXpath(prop.getProperty("Home.Invest.Xpath"),driver);
  124. Thread.sleep(3000);
  125. return this;
  126.  
  127. }
  128.  
  129. public CreateIOIPage clickSubmitButton(RemoteWebDriver driver) throws InterruptedException{
  130. clickByXpath(prop.getProperty("Home.Submit.Xpath"),driver);
  131. Thread.sleep(3000);
  132. return this;
  133.  
  134. }
  135.  
  136. /*public HomePage verifyProduct(String data) throws InterruptedException{
  137. verifyTextByXpath("(//div[@class='whiteboard__whiteboard-list'])[1]//div[@class='instrument'and text()='"+data+"']",data);
  138. //Thread.sleep(3000);
  139. return this;
  140.  
  141. }*/
  142.  
  143. public CreateIOIPage verifyProduct(String data,String data1,String data2,RemoteWebDriver driver) throws InterruptedException{
  144. //if (getTextByXpath("(//div[@class='whiteboard__whiteboard-list'])[1]//div[@class='instrument'and text()='"+data+"']").equals(data) ) {
  145.  
  146. if ((getTextByXpath("((((//div[@class='whiteboard__whiteboard-list'])[1]//div[@class='instrument'and text()='"+data+"'])/ancestor::div[@class='whiteboard__field-wide'])/following-sibling::div[@class='whiteboard__field-wide'])[1]",driver)==data1) && (getTextByXpath("((((//div[@class='whiteboard__whiteboard-list'])[1]//div[@class='instrument'and text()='"+data+"'])/ancestor::div[@class='whiteboard__field-wide'])/following-sibling::div[@class='whiteboard__field-medium whiteboard__field-direction'])",driver)==data2)) {
  147.  
  148. System.out.println("success");
  149.  
  150. }
  151.  
  152.  
  153. //verifyTextByXpath("(//div[@class='whiteboard__whiteboard-list'])[1]//div[@class='instrument'and text()='"+data+"']",data);
  154. //Thread.sleep(3000);
  155. return this;
  156.  
  157. }
  158.  
  159. public CreateIOIPage clickActiveGrid(String data,RemoteWebDriver driver) throws InterruptedException{
  160.  
  161. clickByXpath("((//div[@class='whiteboard__whiteboard-list'])[1]//div[@class='instrument'and text()='"+data+"']/../../../preceding-sibling::div/img)",driver);
  162. Thread.sleep(5000);
  163.  
  164. return this;
  165. }
  166.  
  167. public CreateIOIPage clickAcceptButton(RemoteWebDriver driver) throws InterruptedException{
  168.  
  169.  
  170. clickByXpath(prop.getProperty("Home.Accept.Xpath"),driver);
  171. Thread.sleep(4000);
  172.  
  173. return this;
  174. }
  175.  
  176. public CreateIOIPage clickOpenTrades(RemoteWebDriver driver) throws InterruptedException{
  177.  
  178. clickByXpath(prop.getProperty("Home.OpenTrades.Xpath"),driver);
  179. Thread.sleep(4000);
  180.  
  181. return this;
  182. }
  183.  
  184.  
  185.  
  186. public CreateIOIPage FilterProduct(String data,RemoteWebDriver driver) throws InterruptedException{
  187.  
  188. clickByXpath(prop.getProperty("Home.FilterProduct.Xpath"),driver);
  189. Thread.sleep(2000);
  190. enterByXpath(prop.getProperty("Home.SearchBox.Xpath"), data,driver);
  191. Thread.sleep(2000);
  192. clickByXpath(prop.getProperty("Home.SelectAll.Xpath"),driver);
  193. Thread.sleep(2000);
  194. clickByXpath("//span[text()='"+data+"']",driver);
  195. Thread.sleep(2000);
  196.  
  197. return this;
  198. }
  199.  
  200.  
  201. public CreateIOIPage FilterDirection(String data,RemoteWebDriver driver) throws InterruptedException{
  202.  
  203. clickByXpath(prop.getProperty("Home.FilterDirection.Xpath"),driver);
  204. Thread.sleep(2000);
  205. enterByXpath(prop.getProperty("Home.SearchBox.Xpath"), data,driver);
  206. Thread.sleep(2000);
  207. clickByXpath(prop.getProperty("Home.SelectAll.Xpath"),driver);
  208. Thread.sleep(2000);
  209. clickByXpath("//span[text()='"+data+"']",driver);
  210. Thread.sleep(2000);
  211. clickByXpath(prop.getProperty("Home.CommonPoint.Xpath"),driver);
  212. Thread.sleep(2000);
  213. return this;
  214. }
  215.  
  216. public CreateIOIPage FilterAmount(String data,RemoteWebDriver driver) throws InterruptedException{
  217.  
  218. clickByXpath(prop.getProperty("Home.FilterAmount.Xpath"),driver);
  219. Thread.sleep(2000);
  220. enterById(prop.getProperty("Home.SearchBox.ID"), data,driver);
  221. Thread.sleep(2000);
  222. clickByXpath(prop.getProperty("Home.CommonPoint.Xpath"),driver);
  223. Thread.sleep(2000);
  224. return this;
  225.  
  226. }
  227.  
  228. public CreateIOIPage FilterCCY(String data,RemoteWebDriver driver) throws InterruptedException{
  229.  
  230. clickByXpath(prop.getProperty("Home.FilterCCY.Xpath"),driver);
  231. Thread.sleep(2000);
  232. enterByXpath(prop.getProperty("Home.SearchBox.Xpath"), data,driver);
  233. Thread.sleep(2000);
  234. clickByXpath(prop.getProperty("Home.SelectAll.Xpath"),driver);
  235. Thread.sleep(2000);
  236. clickByXpath("//span[text()='"+data+"']",driver);
  237. Thread.sleep(2000);
  238. clickByXpath(prop.getProperty("Home.CommonPoint.Xpath"),driver);
  239. Thread.sleep(2000);
  240.  
  241. return this;
  242. }
  243.  
  244. public CreateIOIPage VerifyOpenTrades(String data1,String data2,String data3,String data4,String data5,RemoteWebDriver driver) throws InterruptedException{
  245.  
  246. //clickByXpath("//label[text()='Open Trades']");
  247.  
  248. List<WebElement> allRows=driver.findElementsByXPath("(//div[@class='ag-body-container'])/div");
  249. System.out.println("Number of rows available " +allRows.size());
  250.  
  251.  
  252. for (WebElement eachRow : allRows) {
  253. System.out.println("EachRow text value " +eachRow.getText());
  254.  
  255.  
  256.  
  257.  
  258. String str=eachRow.getText();
  259.  
  260.  
  261. if(str.contains(data1) && str.contains(data2) && str.contains(data3) && str.contains(data4) && str.contains(data5)) {
  262.  
  263.  
  264. eachRow.findElement(By.xpath("(//div[@class='ag-body-container'])//div[@class='action-button']")).click();
  265. break;
  266. }
  267.  
  268. /* String tradeDetails[]=str.split("\n");
  269. System.out.println("length of string is " +tradeDetails.length);
  270.  
  271. for(i=0;i<tradeDetails.length;i++) {
  272. System.out.println("trade is " +tradeDetails[i]);
  273. //System.out.println("trade id is " +tradeDetails[1]);
  274. }*/
  275.  
  276.  
  277.  
  278. /*
  279. WebElement tradeID=eachRow.findElement(By.xpath("((//div[@class='ag-body-container'])//div[contains(@class,'ag-cell-no-focus ag-cell ag-cell-not-inline-editing ag-cell-value')])[2]"));
  280. System.out.println("The Trade id of IOI is " +tradeID.getAttribute("colId"));
  281.  
  282. //String str=eachRow.findElement(By.xpath("((//div[@class='ag-body-container'])//div[contains(@class,'ag-cell-no-focus ag-cell ag-cell-not-inline-editing ag-cell-value')])[2]")).getText();
  283. String str=eachRow.findElement(By.xpath("//div[contains(@class,'ag-cell-no-focus ag-cell ag-cell-not-inline-editing ag-cell-value')][2]")).getText();
  284. System.out.println("The Trade id of IOI is " +str);
  285. */
  286. }
  287.  
  288. Thread.sleep(4000);
  289.  
  290. return this;
  291. }
  292.  
  293. public CreateIOIPage clickUnwindSubmitButton(RemoteWebDriver driver) throws InterruptedException{
  294.  
  295. clickByXpath(prop.getProperty("Home.UnwindSubmit.Xpath"),driver);
  296. Thread.sleep(2000);
  297.  
  298. return this;
  299. }
  300. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement