def test_search_one_item(self, get_data): # Selenium Steps log = self.get_logger() log.debug('Starting Test Search One Item') home_page = HomePage(self.driver) home_page.textbox_item().send_keys(get_data['first_item']) results_page = home_page.click_on_search_btn_item() item_page = results_page.click_on_price_list_item() price_item_page = item_page.get_price_item_page() go_to_cart_page = item_page.click_on_add_to_cart_button() cart_page = go_to_cart_page.click_on_go_to_cart_item() price_cart_page = cart_page.get_price_cart_page() # utilities log.info('%s %s %s %s', 'Prices to be compared before formatting:', price_cart_page, 'And:', price_item_page) price_item_page = BaseClass.remove_char(price_item_page) price_cart_page = BaseClass.remove_char(price_cart_page) log.info('%s %s %s %s', 'Prices with chars removed:', price_cart_page, 'To be compared with:', price_item_page) cart_page.delete_btn_item()[0].click() # Validations assert BaseClass.remove_dot(price_cart_page) in BaseClass.remove_dot( price_item_page) assert '0' == home_page.cart_icon_item().text log.debug('Completed Test Search One Item')
def selectService(self): locator=self.driver.find_element_by_id("ServiceGroupId") BaseClass.selectOptionByText(self,locator,self.service) self.driver.find_element_by_name("StartNextButton").click() return AcceptInfoPage(self.driver,self.choose_date,self.timeslot,self.office,\ self.first_name,self.last_name,self.emailaddress,self.phone)
def test_js_alertbox(self): logger = BaseClass.get_logger() logger.info("Start of Alert Box Testing") alert_page = AlertBoxCheckClass(self.driver) alert_page.open_alert_boxes_page() alert_page.open_alert_box() logger.info("End of Alert Box Testing")
def test_multiple_modal_windows(self): logger = BaseClass.get_logger() logger.info("Start of Modal Windows Testing") window_popup_page = MultipleWindowPopupClass(self.driver) window_popup_page.open_window_popup_page() window_popup_page.open_two_window_popup() logger.info("End of Modal Windows Testing")
def test_date_picker(self, get_jquery_date_picker): from_date = get_jquery_date_picker["from_date"] to_date = get_jquery_date_picker["to_date"] logger = BaseClass.get_logger() logger.info("Start of JQuery Date Picker Form Testing") date_picker_page = JQueryDatePickerClass(self.driver) date_picker_page.open_jquery_date_picker() date_picker_page.click_date_picker("from") date_picker_page.select_date(from_date) date_picker_page.click_date_picker("to") date_picker_page.select_date(to_date) logger.info("Verifying Negative Test case on To Date") date_picker_page.click_date_picker("to") date_picker_page.is_date_disabled(from_date, "to") logger.info("Verifying Negative Test case on From Date") date_picker_page.click_date_picker("from") date_picker_page.is_date_disabled(to_date, "from") logger.info("End fo JQuery Date Picker Form Page Testing")
def test_sliders(self, get_slider_range_picker): print("Value is {}".format(get_slider_range_picker["value"])) logger = BaseClass.get_logger() logger.info("Start of Slider Bar Form Testing") sliders_page = RangeSlidersClass(self.driver) sliders_page.open_range_sliders_page() sliders_page.slide_all_sliders(get_slider_range_picker["value"]) logger.info("End of Slider Bar Form Testing")
def test_file_download(self, get_file_download_content_picker): logger = BaseClass.get_logger() logger.info("Start of File Download Testing") file_dw_page = FileDownloadClass(self.driver) file_dw_page.open_file_download_page() file_dw_page.enter_and_download_content( get_file_download_content_picker["content"]) logger.info("End of File Download Testing")
def test_progress_bars(self): logger = BaseClass.get_logger() logger.info("Start of Progress Bar Form Testing") progress_bar_page = DownloadProgressBarClass(self.driver) progress_bar_page.open_progress_bar_page() total_time = progress_bar_page.start_and_measure_download() logger.info("Download took {} seconds to complete".format(total_time)) logger.info("End of Progress Bar Form Testing")
def test_ajax_input_forms(self, get_data_ajax_input_form): logger = BaseClass.get_logger() logger.info("Testing Ajax Input Form Page ") ajax_page = AjaxFormSubmitPageClass(self.driver) ajax_page.open_ajax_form_submit() ajax_page.add_name_to_form(get_data_ajax_input_form["username"]) ajax_page.add_comment_to_form(get_data_ajax_input_form["comments"]) ajax_page.click_submit() ajax_page.check_spinner() ajax_page.check_submit_success_msg() logger.info("End fo Ajax Input Form Page Testing")
def test_AddItemsToCart(self): global homePage,TotalitemsAdded baseclass = BaseClass(self.driver) homePage = GreenCartHomePageObjs(self.driver) homePage.SearchVegitables().click() t.sleep(2) homePage.SearchVegitables().send_keys("br") t.sleep(4) AddItemtoCart=homePage.AddtoCartBtns() TotalitemsAdded=len(AddItemtoCart) print(TotalitemsAdded) for button in AddItemtoCart: button.click()
def scrolltillelementfound(self): BaseClass.scrolltillelement(self, self.scrollelementclick) BaseClass.wait(self, 5)
def __init__(self, driver): self.driver = driver self.base = BaseClass(self.driver) self.driver.implicitly_wait(10)
class TestsalesPage(BaseClass): log = BaseClass.getLogger() # py.test testcases/test_salesPage.py::TestsalesPage::test_verfysaleswithin7days def test_verfysaleswithin7days(self): d1 = DT.date.today() a = d1.strftime("%Y-%m-%d") d2 = d1 + DT.timedelta(days=6) b = d2.strftime("%Y-%m-%d") self.driver.get( "https://sso.eservices.jud.ct.gov/foreclosures/Public/PendPostbyTownList.aspx" ) time.sleep(10) window_before = self.driver.window_handles[0] list = [ 'Milford', 'Trumbull', 'Norwalk', 'Stamford', 'Shelton', 'Fairfield' ] townname = sorted(list) getTownList = self.driver.find_elements( By.XPATH, "//table//tbody//tr//td//div[@id='ctl00_cphBody_Panel1']//a") time.sleep(10) for town in getTownList: if town.text in townname: time.sleep(10) ActionChains(self.driver).context_click(town).key_down( Keys.COMMAND).key_down(Keys.SHIFT).click(town).key_down( Keys.COMMAND).key_down(Keys.SHIFT).perform() time.sleep(10) self.driver.switch_to.window(self.driver.window_handles[-1]) rows = len( self.driver.find_elements( By.XPATH, "//table[@id='ctl00_cphBody_GridView1']//tbody//tr")) columns = len( self.driver.find_elements( By.XPATH, "//table[@id='ctl00_cphBody_GridView1']//tbody//tr//th" )) for r in range(2, rows + 1): for c in range(5, 6): date = self.driver.find_element( By.XPATH, "//table[@id='ctl00_cphBody_GridView1']//tbody//tr[" + str(r) + "]//td[2]//span[1]").text newDate = date[0:10] # 3/27/2021 date_time_obj = datetime.strptime(newDate, "%m/%d/%Y") d3 = date_time_obj.strftime("%Y-%m-%d") if a < b > d3: time.sleep(5) view = self.driver.find_element( By.XPATH, "//table[@id='ctl00_cphBody_GridView1']//tbody//tr[" + str(r) + "]//td[" + str(c) + "]//a") try: ActionChains( self.driver).context_click(view).key_down( Keys.LEFT_CONTROL).click(view).key_up( Keys.LEFT_CONTROL).perform() time.sleep(5) except: ActionChains( self.driver).context_click(view).key_down( Keys.LEFT_CONTROL).click(view).key_up( Keys.LEFT_CONTROL).perform() time.sleep(5) else: self.log.info("Date not falling between 7 days") self.driver.switch_to.window(window_before) time.sleep(5)
def enterFirstName(self, firstnametxt): BaseClass.clickElement(self, self.firstname) # BaseClass.sendkeysExecuter(self,self.firstname,firstnametxt) BaseClass.setText(self, self.firstname, firstnametxt)
def enterLastName(self, lastnametxt): BaseClass.setText(self, self.lastname, lastnametxt)
def doubleclickelement(self): BaseClass.doubleClick(self, self.doubleclick)
def alertelement(self): BaseClass.alert_accept(self, self.alertbutton)
def timedropdown(self): BaseClass.enterDropdownValue_usingVisibleText(self, "Morning", self.timec) BaseClass.wait(self, 5)
def enterDay(self): BaseClass.select_CheckBoxOnlyWhenItsNotSelected(self, self.day) BaseClass.wait(self, 5)
def enterGender(self): BaseClass.select_RadioButtonOnlyWhenItsNotSelected(self, self.genderm) BaseClass.wait(self, 5)
import pytest from selenium import webdriver from pabeobjects.HomePage import HomePage from testdata.LoginPageData import LoginPageData from utilities.BaseClass import BaseClass driver = None baseclass = BaseClass() log = baseclass.getLogger() @pytest.fixture(params=LoginPageData.test_LoginPage_correct_credentials_data) def get_creds(request): return request.param @pytest.fixture(params=["*****@*****.**"]) def get_correct_creds(request): return request.param def pytest_addoption(parser): parser.addoption( "--browser_name", action="store", default="chrome" ) '''@pytest.fixture(scope="function", autouse=True) def setup(request): yield homepage = HomePage(driver) homepage.get_sign_out_link().click()
def test_registration(self): objSeleniumPage = Selenium4TestingPage() base = BaseClass() webdriver = base.setUp() objSeleniumPage.enterUserName(webdriver, config.test_config("Username")) objSeleniumPage.enterPassword(webdriver, config.test_config("Password")) objSeleniumPage.clickOnLoginBtn(webdriver) objSeleniumPage.clickOnRegistrationLink(webdriver) objSeleniumPage.selectPatientCategory( webdriver, config.test_config("patientCategory")) objSeleniumPage.selectTitle(webdriver, config.test_config("title")) objSeleniumPage.enterFirstName(webdriver, config.test_config("firstName")) objSeleniumPage.enterLastName(webdriver, config.test_config("lastName")) objSeleniumPage.enterDateOfBirth(webdriver, config.test_config("dateOfBirth")) objSeleniumPage.enterAge(webdriver, config.test_config("age")) objSeleniumPage.selectGender(webdriver) objSeleniumPage.selectMaritalStatus(webdriver) objSeleniumPage.selectReligion(webdriver, config.test_config("religion")) objSeleniumPage.selectPrimaryLanguage(webdriver) objSeleniumPage.selectRelation(webdriver) objSeleniumPage.selectPatientIdentifier(webdriver) objSeleniumPage.enterAadharNumber(webdriver, config.test_config("aadharNumber")) objSeleniumPage.selectNationality(webdriver) objSeleniumPage.selectVIP(webdriver) objSeleniumPage.selectEducation(webdriver) objSeleniumPage.selectOccupation(webdriver) objSeleniumPage.selectBloodGroup(webdriver) objSeleniumPage.selectCitizenship(webdriver) objSeleniumPage.selectSeniorCitizenProofSubmited(webdriver) objSeleniumPage.enterAddress1(webdriver, config.test_config("address1")) objSeleniumPage.enterPhoneNumber(webdriver, config.test_config("phoneNumber")) objSeleniumPage.selectCountry(webdriver) objSeleniumPage.enterPinNumber(webdriver, config.test_config("pinNumber")) objSeleniumPage.uploadImage(webdriver, config.test_config("image")) objSeleniumPage.clickOnSaveBtn(webdriver) mr_no, success = objSeleniumPage.getAlertText(webdriver) if success == 'Successfully.': logger.info("Registration form submitted successfully") else: logger.info("Registration form not submitted") print("\n" + "MR_NO : " + mr_no) objSeleniumPage.clickOnAlertOkBtn(webdriver) objSeleniumPage.navigateToSearchRegistration(webdriver) objSeleniumPage.searchWithMRNID(webdriver, mr_no) base.take_screenshot('Patient Details') data = [] data = objSeleniumPage.getPatientDataFromRegistrationList(webdriver) logger.info("ID_NO : " + data[0]) logger.info("MR_NO : " + data[1]) logger.info("PNT_NAME : " + data[2]) logger.info("Age : " + data[3]) logger.info("REG_DATE : " + data[4]) #print("EMAIL : " + ) logger.info("ADDRESS : " + data[5]) logger.info("BLOOD_GROUP : " + data[6]) logger.info("STATUS : " + data[7])
def dragdropelements(self): BaseClass.dragAndDrop(self, self.draggable, self.droppable)
def switchiframe(self): BaseClass.switchToFrame(self, self.iframe)