123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- 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);
-
- UtilMethods.waitTillElementIsVisible(logger, driver, opportunityNameOnCreateOppPage);
- UtilMethods.setText(logger, driver.findElement(By.id("opportunityNameOnCreateOppPage")), opportunityName);
-
- UtilMethods.waitTillElementIsVisible(logger, driver, customerRelationshipOnCreateOppPage);
- UtilMethods.setText(logger, driver.findElement(By.id("customerRelationshipOnCreateOppPage")), accountID);
- UtilMethods.clickEnter(logger, driver.findElement(By.id("customerRelationshipOnCreateOppPage")), "Customer Relationship");
-
- UtilMethods.waitTillElementIsVisible(logger, driver, closeDateOnCreateOppPage);
- UtilMethods.setText(logger, driver.findElement(By.id("closeDateOnCreateOppPage")), closeDate);
-
- 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();
-
- 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();
-
- 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;
- }
- }
|