1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package automation_admin;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.support.ui.ExpectedConditions;
- import org.openqa.selenium.support.ui.WebDriverWait;
- public class AutomationCodeGenerator {
- public WebDriver fillFieldsOnOppCreatePage(WebDriver driver, String path, Logger logger, String oppName, String crID, String closeDt, String sellingCountryval, String localCurrencyVal, String IndustrySubSegmentValue) {
- // Data Preparation
- // Get input data from Excel
- // Implement the logic for filling fields on the "Create Opportunity" page based on the pseudo code provided
- // Step 1: Fill Opportunity Name
- WebElement opportunityNameField = new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.id("opportunityName")));
- opportunityNameField.sendKeys(oppName);
- // Step 2: Fill Customer Relationship
- WebElement customerRelationshipField = new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.id("customerRelationship")));
- customerRelationshipField.sendKeys(crID);
- customerRelationshipField.sendKeys(Keys.RETURN); // Trigger autocomplete or dropdown selection
- new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeSelected(By.cssSelector("option[value='" + crID + "']")));
- // Step 3: Fill Close Date
- WebElement closeDateField = new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.id("closeDate")));
- closeDateField.sendKeys(closeDt);
- // Step 4: Select Selling Country
- ((JavascriptExecutor) driver).executeScript("document.querySelector('#sellingCountry').click();");
- new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("option[value='" + sellingCountryval + "']"))).click();
- // Step 5: Select Local Currency
- ((JavascriptExecutor) driver).executeScript("document.querySelector('#localCurrency').click();");
- new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("option[value='" + localCurrencyVal + "']"))).click();
- // Step 6: Select Industry Sub Segment
- ((JavascriptExecutor) driver).executeScript("document.querySelector('#industrySubSegment').click();");
- new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("option[value='" + IndustrySubSegmentValue + "']"))).click();
- // Return modified WebDriver instance
- return driver;
- }
- }
|