genlitex 1 lună în urmă
părinte
comite
386e4fa206
1 a modificat fișierele cu 90 adăugiri și 0 ștergeri
  1. 90 0
      automation_code/fillFieldsOnOppCreatePage.java

+ 90 - 0
automation_code/fillFieldsOnOppCreatePage.java

@@ -0,0 +1,90 @@
+package genlitex_demo.automation_code;
+
+import java.io.File;
+import java.io.IOException;
+import java.time.Duration;
+import java.util.List;
+
+import org.apache.poi.EncryptedDocumentException;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.Select;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.Utility.MethodFactory;
+import com.Utility.ReadExcel;
+import com.Utility.UtilMethods;
+
+public class fillFieldsOnOppCreatePage {
+    private WebDriver driver;
+    private WebDriverWait wait;
+    private ReadExcel excel;
+
+    public fillFieldsOnOppCreatePage(WebDriver driver) {
+        this.driver = driver;
+        this.wait = new WebDriverWait(driver, Duration.ofSeconds(30));
+        PageFactory.initElements(driver, this);
+    }
+
+    public WebDriver fillFieldsOnOppCreatePage(String path, ExtentTest logger, String oppName, String crID,
+            String closeDt, String sellingCountryval, String localCurrencyVal, String IndustrySubSegmentValue,
+            String excelName, String sheetName, int row) throws InterruptedException, EncryptedDocumentException,
+            InvalidFormatException, IOException {
+        
+        excel = ReadExcel.excel(path, excelName);
+
+        String opportunityName = excel.getCellData(sheetName, oppName, row);
+        String accountID = excel.getCellData(sheetName, crID, row);
+        String closeDate = excel.getCellData(sheetName, closeDt, row);
+        String sellingCountry = excel.getCellData(sheetName, sellingCountryval, row);
+        String localCurrency = excel.getCellData(sheetName, localCurrencyVal, row);
+        String IndustrySubSegment = excel.getCellData(sheetName, IndustrySubSegmentValue, row);
+
+        // Set Opportunity Name
+        UtilMethods.waitTillElementIsVisible(logger, driver, opportunityNameOnCreateOppPage);
+        UtilMethods.setText(logger, driver.findElement(By.id("opportunityNameOnCreateOppPage")), opportunityName);
+
+        // Set Customer Relationship
+        UtilMethods.waitTillElementIsVisible(logger, driver, customerRelationshipOnCreateOppPage);
+        UtilMethods.setText(logger, driver.findElement(By.id("customerRelationshipOnCreateOppPage")), accountID);
+        UtilMethods.clickEnter(logger, driver.findElement(By.id("customerRelationshipOnCreateOppPage")), "Customer Relationship");
+
+        // Set Close Date
+        UtilMethods.waitTillElementIsVisible(logger, driver, closeDateOnCreateOppPage);
+        UtilMethods.setText(logger, driver.findElement(By.id("closeDateOnCreateOppPage")), closeDate);
+
+        // Set Selling Country
+        WebElement sellingCountryDropdown = driver.findElement(By.id("sellingCountryDropdown"));
+        ((JavascriptExecutor) driver).executeScript("arguments[0].click();", sellingCountryDropdown);
+        WebElement sellingCountryOption = driver.findElement(By.xpath("//option[text()='" + sellingCountry + "']"));
+        sellingCountryOption.click();
+
+        // Set Local Currency
+        WebElement localCurrencyDropdown = driver.findElement(By.id("localCurrencyDropdown"));
+        ((JavascriptExecutor) driver).executeScript("arguments[0].click();", localCurrencyDropdown);
+        WebElement localCurrencyOption = driver.findElement(By.xpath("//option[text()='" + localCurrency + "']"));
+        localCurrencyOption.click();
+
+        // Set Industry Sub Segment
+        WebElement industrySubSegmentDropdown = driver.findElement(By.id("industrySubSegmentDropdown"));
+        ((JavascriptExecutor) driver).executeScript("arguments[0].click();", industrySubSegmentDropdown);
+        if (IndustrySubSegment.contains("'")) {
+            String[] subSegments = IndustrySubSegment.split("'");
+            for (String subSegment : subSegments) {
+                WebElement subSegmentOption = driver.findElement(By.xpath("//option[text()='" + subSegment + "']"));
+                subSegmentOption.click();
+            }
+        } else {
+            WebElement industrySubSegmentOption = driver.findElement(By.xpath("//option[text()='" + IndustrySubSegment + "']"));
+            industrySubSegmentOption.click();
+        }
+
+        return driver;
+    }
+}