fillFieldsOnOppCreatePage.java 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. package automation_admin;
  2. import java.io.File;
  3. import java.io.IOException;
  4. import java.time.Duration;
  5. import java.util.ArrayList;
  6. import java.util.List;
  7. import java.util.Set;
  8. import org.apache.poi.EncryptedDocumentException;
  9. import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
  10. import org.openqa.selenium.By;
  11. import org.openqa.selenium.JavascriptExecutor;
  12. import org.openqa.selenium.Keys;
  13. import org.openqa.selenium.WebDriver;
  14. import org.openqa.selenium.WebElement;
  15. import org.openqa.selenium.WindowType;
  16. import org.openqa.selenium.interactions.Actions;
  17. import org.openqa.selenium.support.FindBy;
  18. import org.openqa.selenium.support.ui.ExpectedConditions;
  19. import org.openqa.selenium.support.ui.WebDriverWait;
  20. import org.testng.annotations.Test;
  21. import org.testng.asserts.SoftAssert;
  22. import com.Utility.MethodFactory;
  23. import com.Utility.ReadExcel;
  24. import com.Utility.TakeScreenshot;
  25. import com.Utility.TestNGCreation;
  26. import com.Utility.UtilMethods;
  27. import com.relevantcodes.extentreports.ExtentTest;
  28. import com.relevantcodes.extentreports.LogStatus;
  29. public class fillFieldsOnOppCreatePage {
  30. public static WebDriver fillFieldsOnOppCreatePage(WebDriver driver, String path, ExtentTest logger, String oppName,
  31. String crID, String closeDt, String sellingCountryval, String localCurrencyVal,
  32. String IndustrySubSegmentValue, String excelName, String sheetName, int row) throws InterruptedException, EncryptedDocumentException, InvalidFormatException, IOException {
  33. ReadExcel excel = ReadExcel.readExcel(System.getProperty("user.dir") + "/ExcelFiles/" + excelName + ".xlsx", sheetName, row);
  34. String opportunityName = excel.getCellData(oppName);
  35. String accountID = excel.getCellData(crID);
  36. String closeDate = excel.getCellData(closeDt);
  37. String sellingCountry = excel.getCellData(sellingCountryval);
  38. String localCurrency = excel.getCellData(localCurrencyVal);
  39. String IndustrySubSegment = excel.getCellData(IndustrySubSegmentValue);
  40. logger.log(LogStatus.INFO, "closeDate from excel is:" + closeDate);
  41. // Setting Value for Opportunity Name field
  42. UtilMethods.waitTillElementIsVisible(logger, driver, opportunityNameOnCreateOppPage);
  43. UtilMethods.setText(logger, opportunityNameOnCreateOppPage, opportunityName);
  44. // Setting Value for Customer relationship field
  45. Thread.sleep(4000);
  46. UtilMethods.waitTillElementIsVisible(logger, driver, customerRelationshipOnCreateOppPage);
  47. Thread.sleep(4000);
  48. UtilMethods.setText(logger, customerRelationshipOnCreateOppPage, accountID);
  49. Thread.sleep(4000);
  50. UtilMethods.clickEnter(logger, customerRelationshipOnCreateOppPage, "Customer Relationship");
  51. Thread.sleep(4000);
  52. UtilMethods.waitTillElementIsVisible(logger, driver, RT_WinLossSurveyFindingsPage.cRSelection);
  53. Thread.sleep(3000);
  54. UtilMethods.clickOn(logger, cRSelection, "CR");
  55. Thread.sleep(3000);
  56. // Setting Value for Close Date
  57. UtilMethods.waitTillElementIsVisible(logger, driver, closeDateOnCreateOppPage);
  58. Thread.sleep(3000);
  59. UtilMethods.setText(logger, closeDateOnCreateOppPage, closeDate);
  60. Thread.sleep(5000);
  61. JavascriptExecutor executor = (JavascriptExecutor) driver;
  62. WebElement element1 = driver.findElement(
  63. By.xpath("//label[text()='Selling Country/Location']/ancestor::lightning-combobox//input | //label[text()='Selling Country/Location']/ancestor::lightning-combobox//button[@name='SellingCountry__c']"));
  64. Thread.sleep(2000);
  65. UtilMethods.waitTillElementIsVisible(logger, driver, element1);
  66. UtilMethods.clickTheRespectiveButtonByJavaScriptExecutor(driver, logger, element1, "Selling Country");
  67. WebElement selectionElement = driver.findElement(By
  68. .xpath("//label[text()='Selling Country/Location']//ancestor::div[1]//div[@role='listbox']//span/span[text()='"
  69. + sellingCountry + "']"));
  70. executor.executeScript("arguments[0].click();", selectionElement);
  71. // local currency
  72. WebElement element2 = driver
  73. .findElement(By.xpath("//label[text()='Local Currency']/ancestor::lightning-combobox//button"));
  74. UtilMethods.waitTillElementIsVisible(logger, driver, element2);
  75. UtilMethods.clickTheRespectiveButtonByJavaScriptExecutor(driver, logger, element2, "Local Currency");
  76. WebElement selectionElement1 = driver.findElement(
  77. By.xpath("//label[text()='Local Currency']//ancestor::div[1]//div[@role='listbox']//span/span[text()='"
  78. + localCurrency + "']"));
  79. executor.executeScript("arguments[0].click();", selectionElement1);
  80. UtilMethods.waitTillElementIsVisible(logger, driver, industrySubSegmentOnCreateOppPage);
  81. UtilMethods.clickTheRespectiveButtonByJavaScriptExecutor(driver, logger, industrySubSegmentOnCreateOppPage,
  82. "ISS");
  83. Thread.sleep(2000);
  84. if (IndustrySubSegment.equals("H&PS HEALTH-COMM'L PAYER")
  85. || IndustrySubSegment.equals("H&PS HEALTH-COMM'L PROVIDER")) {
  86. String IndustrySubSegmentData[] = IndustrySubSegment.split("'");
  87. UtilMethods.clickTheRespectiveButtonByJavaScriptExecutor(driver, logger,
  88. driver.findElement(By
  89. .xpath("//span[text()='Industry Sub Segment']/../../following-sibling::div//div[contains(text(),'"
  90. + IndustrySubSegmentData[0] + "') and contains(text(),'"
  91. + IndustrySubSegmentData[1] + "')]")),
  92. "industry sub segment");
  93. } else {
  94. UtilMethods.clickTheRespectiveButtonByJavaScriptExecutor(driver, logger,
  95. driver.findElement(
  96. By.xpath("//span[text()='Industry Sub Segment']/../../following-sibling::div//div[text()='"
  97. + IndustrySubSegment + "']")),
  98. "industry sub segment");
  99. }
  100. return driver;
  101. }
  102. }