from selenium import webdriver from selenium.webdriver.common.by import By from openpyxl import load_workbook import logging class RT_OppCreatePage: def __init__(self): self.driver = None def fillFieldsOnOppCreatePage(self, driver, path, logger, oppName, crID, closeDt, sellingCountryval, localCurrencyVal, IndustrySubSegmentValue, excelName, sheetName, row): self.driver = driver wb = load_workbook(excelName) ws = wb[sheetName] # Read data from Excel opp_data = ws[f'{oppName}{row}'].value crID_data = ws[f'{crID}{row}'].value close_date_data = ws[f'{closeDt}{row}'].value selling_country_data = ws[f'{sellingCountryval}{row}'].value local_currency_data = ws[f'{localCurrencyVal}{row}'].value industry_subsegment_data = ws[f'{IndustrySubSegmentValue}{row}'].value # Fill fields self.driver.find_element(By.ID, 'opportunity-name').send_keys(opp_data) self.driver.find_element(By.ID, 'customer-relationship').send_keys(crID_data) self.driver.find_element(By.ID, 'close-date').send_keys(close_date_data) self.driver.find_element(By.ID, 'sales-country').click() self.driver.find_element(By.XPATH, f'//option[text()="{selling_country_data}"]').click() self.driver.find_element(By.ID, 'local-currency').click() self.driver.find_element(By.XPATH, f'//option[text()="{local_currency_data}"]').click() self.driver.find_element(By.ID, 'industry-subsegment').click() self.driver.find_element(By.XPATH, f'//option[text()="{industry_subsegment_data}"]').click() logger.info("Fields filled successfully.") return self.driver def createOppFromCR(self, driver, path, logger, oppName, closeDt, localCurrencyVal, IndustrySubSegmentValue, excelName, sheetName, row): self.driver = driver wb = load_workbook(excelName) ws = wb[sheetName] # Read data from Excel opp_data = ws[f'{oppName}{row}'].value close_date_data = ws[f'{closeDt}{row}'].value local_currency_data = ws[f'{localCurrencyVal}{row}'].value industry_subsegment_data = ws[f'{IndustrySubSegmentValue}{row}'].value # Navigate to Opportunity Related List button self.driver.find_element(By.ID, 'opportunity-related-list-button').click() self.driver.find_element(By.ID, 'new-opportunity-button').click() # Fill opportunity form self.driver.find_element(By.ID, 'opportunity-name').send_keys(opp_data) self.driver.find_element(By.ID, 'local-currency').click() self.driver.find_element(By.XPATH, f'//option[text()="{local_currency_data}"]').click() self.driver.find_element(By.ID, 'close-date').send_keys(close_date_data) self.driver.find_element(By.ID, 'sales-country').click() self.driver.find_element(By.XPATH, f'//option[text()="{industry_subsegment_data}"]').click() logger.info("Opportunity created successfully.") return self.driver