|
@@ -1,28 +1,61 @@
|
|
|
-# Automation Test Script
|
|
|
-
|
|
|
-# 1. Import required Selenium libraries and other dependencies
|
|
|
from selenium import webdriver
|
|
|
-from selenium.webdriver.common.keys import Keys
|
|
|
-
|
|
|
-# 2. Define the test scenario
|
|
|
-test_scenario = "Login Test for Example Application"
|
|
|
-
|
|
|
-# 3. Set up WebDriver
|
|
|
-driver = webdriver.Chrome()
|
|
|
-
|
|
|
-# 4. Navigate to the target webpage
|
|
|
-driver.get("http://example.com/login")
|
|
|
-
|
|
|
-# 5. Locate and interact with elements
|
|
|
-username_field = driver.find_element_by_id("username")
|
|
|
-username_field.send_keys("test_user")
|
|
|
-
|
|
|
-password_field = driver.find_element_by_id("password")
|
|
|
-password_field.send_keys("test_password")
|
|
|
-
|
|
|
-login_button = driver.find_element_by_id("loginButton")
|
|
|
-login_button.click()
|
|
|
-
|
|
|
-# Print completion date and time
|
|
|
-import datetime
|
|
|
-print(f"Completion Date and Time: {datetime.datetime.now()}")
|
|
|
+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
|