|
@@ -3,86 +3,112 @@ package genlitex_demo.automation_code;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.time.Duration;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
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.Keys;
|
|
|
import org.openqa.selenium.WebDriver;
|
|
|
import org.openqa.selenium.WebElement;
|
|
|
+import org.openqa.selenium.WindowType;
|
|
|
+import org.openqa.selenium.interactions.Actions;
|
|
|
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 org.testng.annotations.Test;
|
|
|
+import org.testng.asserts.SoftAssert;
|
|
|
|
|
|
import com.Utility.MethodFactory;
|
|
|
import com.Utility.ReadExcel;
|
|
|
+import com.Utility.TakeScreenshot;
|
|
|
+import com.Utility.TestNGCreation;
|
|
|
import com.Utility.UtilMethods;
|
|
|
+import com.relevantcodes.extentreports.ExtentTest;
|
|
|
+import com.relevantcodes.extentreports.LogStatus;
|
|
|
|
|
|
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 static WebDriver fillFieldsOnOppCreatePage(WebDriver driver, 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 {
|
|
|
|
|
|
- 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);
|
|
|
+ ReadExcel excel = ReadExcel.readExcel(System.getProperty("user.dir") + "/ExcelFiles/" + excelName + ".xlsx", sheetName, row);
|
|
|
|
|
|
- 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);
|
|
|
+ String opportunityName = excel.getCellData(oppName);
|
|
|
+ String accountID = excel.getCellData(crID);
|
|
|
+ String closeDate = excel.getCellData(closeDt);
|
|
|
+ String sellingCountry = excel.getCellData(sellingCountryval);
|
|
|
+ String localCurrency = excel.getCellData(localCurrencyVal);
|
|
|
+ String IndustrySubSegment = excel.getCellData(IndustrySubSegmentValue);
|
|
|
|
|
|
- // Set Opportunity Name
|
|
|
- UtilMethods.waitTillElementIsVisible(logger, driver, opportunityNameOnCreateOppPage);
|
|
|
- UtilMethods.setText(logger, driver.findElement(By.id("opportunityNameOnCreateOppPage")), opportunityName);
|
|
|
+ logger.log(LogStatus.INFO, "closeDate from excel is:" + closeDate);
|
|
|
|
|
|
- // Set Customer Relationship
|
|
|
+ // Setting Value for Opportunity Name field
|
|
|
+ UtilMethods.waitTillElementIsVisible(logger, driver, opportunityNameOnCreateOppPage);
|
|
|
+ UtilMethods.setText(logger, opportunityNameOnCreateOppPage, opportunityName);
|
|
|
+ // Setting Value for Customer relationship field
|
|
|
+ Thread.sleep(4000);
|
|
|
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
|
|
|
+ Thread.sleep(4000);
|
|
|
+ UtilMethods.setText(logger, customerRelationshipOnCreateOppPage, accountID);
|
|
|
+ Thread.sleep(4000);
|
|
|
+ UtilMethods.clickEnter(logger, customerRelationshipOnCreateOppPage, "Customer Relationship");
|
|
|
+ Thread.sleep(4000);
|
|
|
+ UtilMethods.waitTillElementIsVisible(logger, driver, RT_WinLossSurveyFindingsPage.cRSelection);
|
|
|
+ Thread.sleep(3000);
|
|
|
+ UtilMethods.clickOn(logger, cRSelection, "CR");
|
|
|
+ Thread.sleep(3000);
|
|
|
+ // Setting Value for Close Date
|
|
|
UtilMethods.waitTillElementIsVisible(logger, driver, closeDateOnCreateOppPage);
|
|
|
- UtilMethods.setText(logger, driver.findElement(By.id("closeDateOnCreateOppPage")), closeDate);
|
|
|
+ Thread.sleep(3000);
|
|
|
+ UtilMethods.setText(logger, closeDateOnCreateOppPage, closeDate);
|
|
|
+ Thread.sleep(5000);
|
|
|
+ JavascriptExecutor executor = (JavascriptExecutor) driver;
|
|
|
+ WebElement element1 = driver.findElement(
|
|
|
+ By.xpath("//label[text()='Selling Country/Location']/ancestor::lightning-combobox//input | //label[text()='Selling Country/Location']/ancestor::lightning-combobox//button[@name='SellingCountry__c']"));
|
|
|
+ Thread.sleep(2000);
|
|
|
+ UtilMethods.waitTillElementIsVisible(logger, driver, element1);
|
|
|
+ UtilMethods.clickTheRespectiveButtonByJavaScriptExecutor(driver, logger, element1, "Selling Country");
|
|
|
+ WebElement selectionElement = driver.findElement(By
|
|
|
+ .xpath("//label[text()='Selling Country/Location']//ancestor::div[1]//div[@role='listbox']//span/span[text()='"
|
|
|
+ + sellingCountry + "']"));
|
|
|
+ executor.executeScript("arguments[0].click();", selectionElement);
|
|
|
+ // local currency
|
|
|
+ WebElement element2 = driver
|
|
|
+ .findElement(By.xpath("//label[text()='Local Currency']/ancestor::lightning-combobox//button"));
|
|
|
+ UtilMethods.waitTillElementIsVisible(logger, driver, element2);
|
|
|
+ UtilMethods.clickTheRespectiveButtonByJavaScriptExecutor(driver, logger, element2, "Local Currency");
|
|
|
+ WebElement selectionElement1 = driver.findElement(
|
|
|
+ By.xpath("//label[text()='Local Currency']//ancestor::div[1]//div[@role='listbox']//span/span[text()='"
|
|
|
+ + localCurrency + "']"));
|
|
|
+ executor.executeScript("arguments[0].click();", selectionElement1);
|
|
|
+ UtilMethods.waitTillElementIsVisible(logger, driver, industrySubSegmentOnCreateOppPage);
|
|
|
+ UtilMethods.clickTheRespectiveButtonByJavaScriptExecutor(driver, logger, industrySubSegmentOnCreateOppPage,
|
|
|
+ "ISS");
|
|
|
+ Thread.sleep(2000);
|
|
|
|
|
|
- // 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();
|
|
|
+ if (IndustrySubSegment.equals("H&PS HEALTH-COMM'L PAYER")
|
|
|
+ || IndustrySubSegment.equals("H&PS HEALTH-COMM'L PROVIDER")) {
|
|
|
|
|
|
- // 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();
|
|
|
+ String IndustrySubSegmentData[] = IndustrySubSegment.split("'");
|
|
|
+ UtilMethods.clickTheRespectiveButtonByJavaScriptExecutor(driver, logger,
|
|
|
+ driver.findElement(By
|
|
|
+ .xpath("//span[text()='Industry Sub Segment']/../../following-sibling::div//div[contains(text(),'"
|
|
|
+ + IndustrySubSegmentData[0] + "') and contains(text(),'"
|
|
|
+ + IndustrySubSegmentData[1] + "')]")),
|
|
|
+ "industry sub segment");
|
|
|
|
|
|
- // 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();
|
|
|
+
|
|
|
+ UtilMethods.clickTheRespectiveButtonByJavaScriptExecutor(driver, logger,
|
|
|
+ driver.findElement(
|
|
|
+ By.xpath("//span[text()='Industry Sub Segment']/../../following-sibling::div//div[text()='"
|
|
|
+ + IndustrySubSegment + "']")),
|
|
|
+ "industry sub segment");
|
|
|
}
|
|
|
|
|
|
return driver;
|