Dosyaları ekledim.
. / topfolder / addnewproperty / TCADDNEWP01.py
import unittest
import HtmlTestRunner
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
from ..commons.unittestcase import TestRE
from ..commons.common_functions import AddProperty
from ..commons.locators import CommonPageLocators, SigninPageLocators, AddPropertyPageLocators
from ..commons import property_update_values as pv
class TestAddNewProperty01(TestRE):
def setUp(self):
super().setUp()
self.add_property = AddProperty(self.driver)
self.signout = AddProperty(self.driver)
self.add_property.signin(SigninPageLocators.EMAIL_INPUT, SigninPageLocators.PASSWORD_INPUT, SigninPageLocators.LOGIN_BUTTON)
self.driver.maximize_window()
def test_add_new_property_01(self):
self.add_property.add_property_button(AddPropertyPageLocators.ADD_PROPERTY_BUTTON)
self.add_property.prop_name(AddPropertyPageLocators.PROPERTY_NAME, 'AddNewP01')
self.add_property.prop_address(AddPropertyPageLocators.PROPERTY_ADDRESS, pv.address)
self.add_property.investment_inflation(AddPropertyPageLocators.INVESTMENT_INFLATION, pv.investment_inflation_amount)
self.add_property.investment_inflation_currency(AddPropertyPageLocators.INVESTMENT_INFLATION_CURRENCY, pv.investment_inflation_currency)
self.add_property.repatriation_inflation(AddPropertyPageLocators.REPATRIATION_INFLATION, pv.repatriation_inflation_amount)
self.add_property.repatriation_inflation_currency(AddPropertyPageLocators.REPATRIATION_INFLATION_CURRENCY, pv.repatriation_inflation_currency)
self.add_property.analysis_start_date(AddPropertyPageLocators.ANALYSIS_START_DATE, pv.analysis_start_date)
self.add_property.general_partner(AddPropertyPageLocators.GENERAL_PARTNER, pv.general_partner)
self.add_property.default_rentable_space_designation(AddPropertyPageLocators.DEFAULT_RENTABLE_SPACE_DESIGNATION, pv.default_rentable_space_designation_type)
self.add_property.identifier(AddPropertyPageLocators.IDENTIFIER)
self.add_property.rentable(AddPropertyPageLocators.RENTABLE, pv.rentable_area)
self.add_property.market_gross_rental_rate(AddPropertyPageLocators.MARKET_GROSS_RENTAL_RATE, pv.market_gross_rental_rate_amount)
self.add_property.long_term_market_vacancy_rate(AddPropertyPageLocators.LONG_TERM_MARKET_VACANCY_RATE, pv.long_term_market_vacancy_rate_percent)
self.add_property.overall_property_cap_rate(AddPropertyPageLocators.OVERALL_PROPERTY_CAP_RATE, pv.overall_property_cap_rate_percent)
self.add_property.expected_inflation_rate(AddPropertyPageLocators.EXPECTED_INFLATION_RATE, pv.expected_inflation_rate_percent)
self.add_property.landlord_discount_rate(AddPropertyPageLocators.LANDLORD_DISCOUNT_RATE, pv.landlord_discount_rate_percent)
self.add_property.full_market_value(AddPropertyPageLocators.FULL_MARKET_VALUE, pv.full_market_value_amount)
self.add_property.currency_symbols(AddPropertyPageLocators.CURRENCY_SYMBOLS, AddPropertyPageLocators.CURRENCY_SYMBOL)
self.add_property.purchase_price(AddPropertyPageLocators.PURCHASE_PRICE, pv.purchase_price_amount)
self.add_property.loan_to_value(AddPropertyPageLocators.LOAN_TO_VALUE, pv.loan_to_value_amount)
self.add_property.interest_rate(AddPropertyPageLocators.INTEREST_RATE, pv.interest_rate)
self.add_property.operating_expenses(AddPropertyPageLocators.OE_NONCONT_TYPE, pv.oe_noncont_type_text, AddPropertyPageLocators.OE_NONCONT_RATE, pv.oe_noncont_rate_amount, AddPropertyPageLocators.OE_NONCONT_YOY, pv.oe_noncont_yoy_percent)
self.add_property.isCAM(AddPropertyPageLocators.OE_NONCONT_isCAM_input)
self.add_property.improvements(AddPropertyPageLocators.IMPROVEMENT_TYPE, pv.improvement_type, AddPropertyPageLocators.IMPROVEMENT_COST, pv.improvement_cost)
self.add_property.leasing_commissions(AddPropertyPageLocators.NEW_LEASE_RATE_PERCENT, pv.new_lease_rate_percent, AddPropertyPageLocators.NEW_LEASE_METHOD, AddPropertyPageLocators.NL_METHOD_NET)
self.add_property.leasing_commissions(AddPropertyPageLocators.RENEWAL_EXTENSION_RATE_PERCENT, pv.renewal_extension_percent, AddPropertyPageLocators.RENEWAL_EXTENSION_METHOD, AddPropertyPageLocators.RE_METHOD_NET)
self.add_property.click(AddPropertyPageLocators.SAVE_BUTTON)
self.add_property.assert_elem_text(CommonPageLocators.HEADER_PAGE_NAME, 'Properties') # final assertion1
self.add_property.assert_elem_text(CommonPageLocators.FINAL_FIRST_PROPERTY, 'AddNewP01') # final assertion2
print('Final Assertion-current_url is ', self.driver.current_url)
self.add_property.screen_shot("/home/hakan/Projects/AutomationTests/re/topfolder/screenshots/ADDNEWP-01-final_assertion.png")
. / run.py
import unittest
import HtmlTestRunner
from topfolder.addnewproperty import TCADDNEWP01
if __name__ == '__main__':
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='/home/hakan/Projects/AutomationTests/re/topfolder/results'))
. / topfolder / commons / common_functions.py
from .locators import CommonPageLocators, SigninPageLocators
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
class BasePage:
def __init__(self, driver):
self.driver = driver
def just_find_tag(self, by_locator):
WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator)).text
def click(self, by_locator):
WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located(by_locator)).click()
def tab(self, by_locator):
WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator)).send_keys(Keys.TAB)
def hover_to(self, by_locator):
element = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator))
ActionChains(self.driver).move_to_element(element).perform()
def assert_elem_text(self, by_locator, elem_text):
element = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator))
assert element.text == elem_text
def signout(self, by_locator):
elem = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator))
elem.click()
def signin(self, by_locator1, by_locator2, by_locator3):
WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator1)).send_keys('admin@abc.local')
WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator2)).send_keys('abcdef1!')
elem = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator3))
elem.click()
def wait_(self, tm):
import time
time.sleep(tm)
def block_and_delete(self, by_locator):
elem = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator))
elem.send_keys(Keys.CONTROL + 'a')
elem.send_keys(Keys.DELETE)
def send_keys_(self, by_locator, text):
elem = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator))
elem.send_keys(Keys.CONTROL + 'a')
elem.send_keys(Keys.DELETE)
elem.send_keys(text)
def add_property_button(self, by_locator):
WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator)).click()
def scrollTo(self, scroll):
import time
time.sleep(3)
self.driver.execute_script(scroll)
# "window.scrollTo(0,700)"
def screen_shot(self, file_name):
self.driver.get_screenshot_as_file(file_name)
# "screen_shots/ADDNEWP-07-final_assertion.png"
class AddProperty(BasePage):
def __init__(self, driver):
super().__init__(driver)
self.driver.get('https://def.abcdev.io/')
. / topfolder / commons / locators.py
from selenium .webdriver.common.by import By
class CommonPageLocators:
SIGNOUT_BUTTON = (By.XPATH, '//*[@id="__next"]/div/div/div[1]/div/div[2]/div[2]/div')
HEADER_DROP_BUTTON = (By.XPATH, '//*[@id="__next"]/div/div/div[1]/div/div[2]/div[2]/button')
HEADER_PAGE_NAME = (By.CLASS_NAME, 'ui.inverted.header')
FINAL_FIRST_PROPERTY = (By.XPATH, '//*[@id="__next"]/div/div/div[2]/div/div/div[2]/div/div/div[1]/div[3]/div[1]')
UPDATABLE_PROP = (By.XPATH, '//*[@id="__next"]/div/div/div[2]/div/div/div[2]/div/div/div[1]/div[1]')
class SigninPageLocators:
EMAIL_INPUT = (By.NAME, 'email')
PASSWORD_INPUT = (By.NAME, 'password')
LOGIN_BUTTON = (By.XPATH, '//*[@id="__next"]/div/div/form/div/button')
...
# Save and Cancel
SAVE_BUTTON = (By.XPATH, '//*[@id="__next"]/div/div/div[2]/div/div[2]/div[8]/div/button[2]')
CANCEL = (By.XPATH, '//*[@id="__next"]/div/div/div[2]/div/div[2]/div[8]/div/button[1]')
. / topfolder / commons / unittestcase.py
import unittest
from selenium import webdriver
class TestRE(unittest.TestCase):
def setUp(self):
chrome_options = webdriver.ChromeOptions()
# chrome_options.add_argument('headless')
chrome_options.add_argument('window-size=1920x1080')
self.driver = webdriver.Chrome(executable_path='/home/hakan/Projects/AutomationTests/drivers/chromedriver_linux64 (1)/chromedriver', options=chrome_options)
def tearDown(self):
self.driver.quit()
self.driver.stop_client()