class GrouponPage(BasePage): import_codes = Find(by=By.XPATH, value="//div[@name='inputCodeForm']//button") groupon_list = Finds(GrouponList, by=By.XPATH, value="//tbody/tr") details = Find(by=By.XPATH, value="//a[text()='Details']") view_redemptions = Find(by=By.XPATH, value="//a[text()='View Redemptions']") view_codes = Find(by=By.XPATH, value="//a[text()='View Codes']") code_list_not_redeemed = Finds(CodeList, by=By.XPATH, value="//td[text()=0]/..") code_list_redeemed = Finds(CodeList, by=By.XPATH, value="//td[text()=1]/..") def select_groupon(self, name): for item in self.groupon_list: if item.groupon_name.text == name: item.edit_button.click() break def copy_code(self, order): for item in self.code_list_not_redeemed: if item.redeemed.text == "0": order.promo_code = item.code.text break def copy_redeemed_code(self, order): for item in self.code_list_redeemed: if item.redeemed.text == "1": order.promo_code = item.code.text break
class ListResults(BasePage): list_results = Finds(ResultItem, by=By.XPATH, value="//div[@class='ModelList__ModelBlockRow']") max_prices = Finds( by=By.XPATH, value= "//div[@class='ModelList__ModelBlockRow']//span[contains(@class, 'PriceBlock" "__PriceLastValue')]/span") def get_titles_list(self): wait(lambda: len(self.list_results) == RESULTS_ON_PAGE) titles = [item.title.text for item in self.list_results] LOGGER.info("Titles on the page: '%s'", titles) return titles def get_min_prices_list(self): min_prices = [ int(item.min_price.text.replace(" ", "").replace(",", "")) / 100 for item in self.list_results ] LOGGER.info("Min prices on the page: '%s'", min_prices) return min_prices def get_max_prices_list(self): max_prices = [ int(max_price.text.replace(" ", "").replace(",", "")) / 100 for max_price in self.max_prices ] LOGGER.info("Max prices on the page: '%s'", max_prices) return max_prices
class CatalogPage(BasePage): subsections = Finds(by=By.XPATH, value="//ul[@class='catalog-bar__list']/li/a") subsection_page_header = Find(by=By.CSS_SELECTOR, value="h1[class='schema-header__title']") products = Finds(by=By.XPATH, value="//a[@data-bind='attr: {href: product.html_url}']/span/..") compare_button = Find(by=By.CSS_SELECTOR, value="a[class ='compare-button__sub compare-button__sub_main']") remove_compare_icon = Find(by=By.CSS_SELECTOR, value="a[title='Очистить список сравнения']") remove_compare_button = Find(by=By.CSS_SELECTOR, value="a[class='compare-button__sub']") def click_subsection_link(self, index): self.subsections[index].click() def click_product_link(self, index): wait(self.subsection_page_header.is_displayed) self.products[index].click() def click_compare(self): wait(self.compare_button.is_displayed) self.compare_button.click() def click_remove_compare_icon(self): wait(self.remove_compare_icon.is_displayed) self.remove_compare_icon.click() def click_remove_compare_button(self): wait(self.remove_compare_button.is_displayed) self.remove_compare_button.click()
class EventScheldulerPage(BasePage): scheldule_type = Find(by=By.XPATH, value="//select[@id='schedule_type']") onetime_field = Find(by=By.XPATH, value="//input[@id='onetime_date']") next_button_calendar_begin = Find(by=By.XPATH, value="//button[@class='pika-next']") next_button_calendar_enddate_rep = Find(by=By.XPATH, value="/html/body/div[5]/div/div/button[2]") next_button_calendar_enddate_repmult = Find(by=By.XPATH, value="/html/body/div[7]/div/div/button[2]") date_calendar = Finds(by=By.XPATH, value="//button[@class='pika-button pika-day']") onetime_hour = Find(by=By.XPATH, value="//select[@id='onetime_time_hour']") onetime_minute = Find(by=By.XPATH, value="//select[@id='onetime_time_minute']") onetime_ampm = Find(by=By.XPATH, value="//select[@id='onetime_time_ampm']") onetime_add = Find(by=By.XPATH, value="//button[@id='addevents_onetime']") rep_begin_field = Find(by=By.XPATH, value="//input[@id='dayonce_datebegin']") rep_end_field = Find(by=By.XPATH, value="//input[@id='dayonce_dateend']") date_calendar_end = Finds(by=By.XPATH, value="//button[@class='pika-button pika-day']") rep_hour = Find(by=By.XPATH, value="//select[@id='dayonce_timestart_hour']") rep_minute = Find(by=By.XPATH, value="//select[@id='dayonce_timestart_minute']") rep_ampm = Find(by=By.XPATH, value="//select[@id='dayonce_timestart_ampm']") rep_add = Find(by=By.XPATH, value="//button[@id='addevents_dayonce']") rep_mult_begin_field = Find(by=By.XPATH, value="//input[@id='daymultiple_datebegin']") rep_mult_end_field = Find(by=By.XPATH, value="//input[@id='daymultiple_dateend']") runs_mult_field = Find(by=By.XPATH, value="//input[@id='daymultiple_everyminutes']") rep_mult_hours_begin = Find(by=By.XPATH, value="//select[@id='daymultiple_timebegin_hour']") rep_mult_min_begin = Find(by=By.XPATH, value="//select[@id='daymultiple_timebegin_minute']") rep_mult_appm_begin = Find(by=By.XPATH, value="//select[@id='daymultiple_timebegin_ampm']") rep_mult_hours_end = Find(by=By.XPATH, value="//select[@id='daymultiple_timeend_hour']") rep_mult_min_end = Find(by=By.XPATH, value="//select[@id='daymultiple_timeend_minute']") rep_mult_appm_end = Find(by=By.XPATH, value="//select[@id='daymultiple_timeend_ampm']") rep_every_min = Find(by=By.XPATH, value="//input[@id='daymultiple_everyminutes']") rep_add_mult = Find(by=By.XPATH, value="//button[@id='addevents_daymultiple']") popup_OK = Find(by=By.XPATH, value="//button[@data-bb-handler='ok']")
class CalendarPage(BasePage): days_list = Finds(Day, by=By.XPATH, value="//div[@class='cal_month_day ng-scope']") without_booking = Find(by=By.XPATH, value="//label[@for='hide-without-booking']") preloader_image = Find(by=By.XPATH, value="//img[@src='/assets/images/preloader.gif']") view_all_links = Finds(by=By.XPATH, value=".//a[text()='[View All]']")
class GuidePage(BasePage): url = 'https://ci004.godo.io/g_calendar.aspx' activity_name = Find(by=By.XPATH, value="//select[@id='activity_id']") hide_events = Find( by=By.XPATH, value="//input[@ng-model='calendar.hideEventsWithoutBooking']") date_picker = Find(by=By.XPATH, value="//i[@ng-model='calendar.customDate']") date_picker_next = Find( by=By.XPATH, value="//i[@class='glyphicon glyphicon-chevron-right']") day_button = Find( by=By.XPATH, value="//a[@ng-click='$event.preventDefault(); calendar.setDayView()']" ) day_date = Find( by=By.XPATH, value="//h3[@class='col-sm-5 col-md-4 cal_header ng-binding']") day_slots = Finds(EventTicket, By.XPATH, value="//div[@class='col-xs-12 cal_day_event']") days_date_picker = Finds(by=By.XPATH, value="//span[@class='ng-binding']") time = Finds(by=By.XPATH, value="//div[@class='cal_event_tickets_avail ng-binding']") date_header = Find(by=By.XPATH, value="//span[@class='cal-header-text ng-binding']") time_slots = Finds( EventTicket, By.XPATH, value="//div[@class='col-sm-3 cal_event_time ng-binding']") close_button = Find( by=By.XPATH, value= "//i[@class='close-x fa fa-times pull-right visible-md visible-lg hidden-xs hidden-sm']" ) date_time_title = Find(by=By.XPATH, value="//span[@id='startTime']") activity_name_title = Find(by=By.XPATH, value="//span[@id='activityName']") check_in = Find(by=By.XPATH, value="//input[@data-checkincheckbox]") event_complete = Find(by=By.XPATH, value="//button[@id='markeventcomplete']") next_month = Find( by=By.XPATH, value="//button[@class='btn btn-default btn-sm pull-right uib-right']") profile_dropdown = Find(by=By.XPATH, value='//a[@data-toggle="dropdown"]') logout_button = Find( by=By.XPATH, value='//*[@id="wrapper"]/div[2]/div[2]/div/div/ul/li[3]/ul/li[5]/a') add_booking = Find(by=By.XPATH, value="//button[contains(@ng-click,'drawer.open')]") event_tickets = Finds(by=By.XPATH, value="//div[@class='cal_week_event ng-scope']") search_field = Find(by=By.XPATH, value='//input[@ng-change="calendar.search()"]') customer_tickets = Find( by=By.XPATH, value='//*[@id="dtEventDetails"]/tbody/tr[1]/td[2]/b')
class NavigationCatalogPageLocators(BasePage): sections = Finds( by=By.XPATH, value="//span[contains(@class, 'Catalog__SectionLevel1')]") subsections = Finds( by=By.XPATH, value="//span[contains(@class, 'Catalog__SectionLevel3')]/a") choose_laptop = Find( by=By.XPATH, value= './/*[@class="VisitSection__BlockRecipesName"]//*[text()="Ноутбуки"]')
class LaptopSearchPage(BasePage): model_list_checkboxes = Finds(by=By.XPATH, value='//*[@id="Attr_prof_1000"]//label') diagonal_list_checkboxes = Finds(by=By.XPATH, value='//*[@id="Attr_prof_5828"]//label') diagonal_block = Find(by=By.CSS_SELECTOR, value='div.ModelFilter__TipAttrWapper:nth-child(7)') show_results_button = Find(by=By.XPATH, value="//div[@data-param='filter_buttons']" "//span[@class='ModelFilter__CountItems']") price_from_button = Find(by=By.XPATH, value="//input[@id='minnum_45']") price_to_button = Find(by=By.XPATH, value="//input[@id='maxnum_45']") diagonal_block_extended = Find(by=By.CSS_SELECTOR, value='#Attr_prof_5828') laptops_block_extended = Find(by=By.CSS_SELECTOR, value='#Attr_prof_1000') model_list_expand = Find(by=By.CSS_SELECTOR, value="span[data-idgroup='prof_1000']") close_button = Find(by=By.XPATH, value="//a[@data-ga='sbros']")
class AddonPage(BasePage): # Create or Edit add-on. addon_name = Find(by=By.XPATH, value="//input[@id='addon_name']") addon_price = Find(by=By.XPATH, value="//input[@id='addon_price']") addon_description = Find(by=By.XPATH, value="//textarea[@id='addon_description']") addon_status = Find(by=By.XPATH, value="//select[@id='addon_status']") save_addon = Find(by=By.XPATH, value="//button[@id='submitaddon']") cancel_addon = Find(by=By.XPATH, value="//a[text()='Cancel']") # Add addon type. add_type_button = Find(by=By.XPATH, value="//button[@id='addAddonExt']") addon_select = Find(by=By.XPATH, value="//select[@id='addon_id']") type_name = Find(by=By.XPATH, value="//input[@id='addon_ex_name']") type_price = Find(by=By.XPATH, value="//input[@id='addon_ex_price']") type_status = Find(by=By.XPATH, value="//input[@id='addon_ex_status']") save_type = Find(by=By.XPATH, value="//button[@id='submitaddonex']") cancel_type = Find(by=By.XPATH, value="//button[@id='canceladdonex']") addon_types_table = Finds(TypesList, by=By.XPATH, value="//table[@id='dtAddonEx']/tbody/tr") # Add activity. add_activity = Find(by=By.XPATH, value="//button[@id='addAddonToActivity']") select_activity = Find(by=By.XPATH, value="//select[@id='activity_id']") save_activity = Find(by=By.XPATH, value="//button[@id='submitaddonactivity']") cancel_activity = Find(by=By.XPATH, value="//button[@id='canceladdonactivity']") activity_table = Finds(ActivityList, by=By.XPATH, value="//div[@id='addonsactivitylist']//tbody/tr") pop_up = Find(by=By.XPATH, value="//div[@class='bootbox-body']") pop_up_ok_button = Find( by=By.XPATH, value="//div[@class='modal-footer']/button[text()='OK']") pop_up_cancel_button = Find( by=By.XPATH, value="//div[@class='modal-footer']/button[text()='Cancel']") def select(self, web_element, option): Select(web_element).select_by_visible_text(option) def wait_redirection(self): old_url = self._driver.current_url wait(lambda: self._driver.current_url != old_url)
class Guest(WebElement): name = Find(by=By.XPATH, value="./td[2]/a") tickets = Finds(by=By.XPATH, value=".//span[@ng-repeat='ticket in booking.tickets']") addons = Finds(by=By.XPATH, value=".//span[@ng-repeat='addon in booking.addons']") amount_due = Find(by=By.XPATH, value="./td[3]/a") phone = Find(by=By.XPATH, value="./td[2]/div[2]/a") email = Find(by=By.XPATH, value="./td[2]/div[1]/a") actions = Find(by=By.XPATH, value="./td[8]//button") refund = Find(by=By.XPATH, value=".//li/a[text()='Refund']") cancel = Find(by=By.XPATH, value=".//li/a[text()='Cancel Guest']") rain_check = Find(by=By.XPATH, value=".//li/a[text()='Rain Check']")
class RequestOFFPage(BasePage): url = 'https://ci004.godo.io/guide_requestOff.aspx' request_off_entry = Finds( by=By.XPATH, value="//tr[@class='row']|//tr[@class='odd']|//tr[@class='even']") approval_dropdown = Finds( by=By.XPATH, value="//select[contains(@id, 'requestoff_status_')]") not_approved_button = Find(by=By.XPATH, value="//label[@class ='btn btn-danger']") approved_button = Find(by=By.XPATH, value="//label[@class ='btn btn-success']") tables = Finds(by=By.XPATH, value="//table[@id = 'dtRequestOff']") rows = Finds(by=By.XPATH, value="//*[@id='dtRequestOff']/tbody/tr")
class LaptopsPageLocators(BasePage): laptops_name = Finds(by=By.XPATH, value='.//*[@class="ModelFilter__CheckboxLink"]/a') laptops_price_min_input = Find(by=By.CSS_SELECTOR, value="#minnum_45") laptops_price_max_input = Find(by=By.CSS_SELECTOR, value="#maxnum_45") show_laptops_diagonal_results = Find( by=By.XPATH, value=".//*[@id='Attr_prof_5828']/div/div[2]/span[1]") show_laptops_name_results = Find( by=By.XPATH, value=".//*[@id='Attr_prof_1000']/div/div[2]/span[1]") diagonal_checkbox = Finds(by=By.XPATH, value='.//*[@class="ModelFilter__CheckboxLink"]')
class Sidebar(KibanaBasePage): ''' Kibana Login Page ''' DISCOVER = 'Discover' VISUALIZE = 'Visualize' DASHBOARD = 'Dashboard' TIMELION = 'Timelion' MACHINE_LEARNING = 'Machine Learning' GRAPH = 'Graph' DEV_TOOLS = 'Dev Tools' MONITORING = 'Monitoring' MANAGEMENT = 'Management' COLLAPSE = 'Collapse' EXPAND = 'Expand' LOGOUT = 'Logout' sidebar_main = Find(by=By.CLASS_NAME, value='global-nav__links') sidebar_links = Finds(Link, **data_test_subj('global-nav-link appLink')) def __init__(self, **kwargs): super().__init__(**kwargs) def loaded(self): wait(lambda: self.is_element_present('sidebar_main') is True) def click_link_text(self, text): for link in self.sidebar_links: if link.text == text: link.click() break def is_link_visible(self, text): return text in self.sidebar_main.text.split('\n')
class LoginPage(BasePage): def __init__(self, domain, *args, **kwargs): super().__init__(url=domain, *args, **kwargs) # Base login page. login_input = Find(by=By.NAME, value="username") password_input = Find(by=By.NAME, value="password") login_button = Find(by=By.CSS_SELECTOR, value="input[type=submit]") # Page to select company for call center user. ccu_companyList.aspx logout_button = Find(by=By.XPATH, value="//a[@href='/login.aspx?command=logout']") company_list = Finds(CompanyList, by=By.XPATH, value="//tbody/tr") def choose_company(self, company): for item in self.company_list: title = item.company_name.text if title == company: item.login_button.click() break def get_url(self): return self._driver.current_url
def FindsEither(ui_type=WebElement, selectors=None, context=None): startTime = time() originalTimeout = webium.settings.implicit_timeout webium.settings.implicit_timeout = 0 notTimeout = True while notTimeout: for ident in selectors: try: itemsFound = Finds(ui_type=ui_type, by=ident[0], value=ident[1], context=context) itemsFound._search_element() if len(itemsFound._target_element) != 0: return itemsFound._target_element except: pass if time() - startTime > originalTimeout: notTimeout = False
class TimeRangeQuickList(KibanaBasePage): time_range_quick_list = Finds(TimeRangeQuickLink, by=By.CSS_SELECTOR, value='div.kbn-timepicker-section > ul > li > a') def __init__(self, **kwargs): super().__init__(**kwargs) wait(lambda: len(self.time_range_quick_list) > 0, waiting_for='Time ranges in quick list')
class Day(WebElement): date = Find(by=By.XPATH, value="./div[@class='cal_month_day_date ng-binding']") events_list = Finds(Event, by=By.XPATH, value=".//div[@class='cal_week_event ng-scope']") view_all = Find(by=By.XPATH, value=".//a[text()='[View All]']")
class PaymentsPage(BasePage): '''Объект страницы платежи search_input {WebElemnt} - Поле для поиска по названию или ИНН communal_payment {WebElemnt} - ссылка на выбор категории "ЖКХ" proposal_list {WebElemnt} - список совпадений, при вводе значений в search_input ''' search_input = Find( by=By.CSS_SELECTOR, value="input[placeholder*='Название или ИНН получателя']" ) communal_payment = Find(by=By.CSS_SELECTOR, value="div[aria-label='ЖКХ'") proposal_list = Finds(by=By.CSS_SELECTOR, value="div[data-qa-file='GridColumn']") def proposal_list_text(self): """Возвращает текст элементов из списка совпадений Returns: [List] """ return [provider.text for provider in self.proposal_list] def stateless_input(self, name): """Поиск по названию/ИНН. После ввода в поискову строку, ожидает появление списка совпадений Arguments: name {str} -- [Название/ИНН] """ self.search_input.send_keys(name) wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div[data-qa-file='GridColumn']")))
class VacanciesPage(BasePage): vacancies_list = Finds(Vacancy, By.XPATH, '//div[@id="careers-vacancies"]/div[@data-id]') def __init__(self): super(VacanciesPage, self).__init__(url='http://wargaming.com/en/careers/vacancies/')
class TypedPage(BasePage): links = Finds(Link, By.TAG_NAME, 'a') def __init__(self): super(TypedPage, self).__init__(url='http://wargaming.net') def get_unsecured_links(self): return filter(lambda link: not link.is_secure(), self.links)
class ComparePage(BasePage): compare_page_title = Find(by=By.CSS_SELECTOR, value="h1[class='b-offers-title']") compared_products = Finds( by=By.XPATH, value="//th[@class='product-table__cell']/div/div/a") def get_product_name(self, index): return self.compared_products[index].text
class MainPage(BasePage): ver_label = Find(by=By.XPATH, value='//*[@id="verNo"]/div') reboot_link_btn = Find(by=By.LINK_TEXT, value="Reboot") reboot_ok_btn = Find(by=By.XPATH, value="//button[@class='button green']") label_list = Finds( by=By.XPATH, value= '//div[@class="ant-col ant-form-item-control-wrapper"]/div/span/div/div[@class="ant-row"]/div[1]' )
class GuidePage(BasePage): activity_name = Find(by=By.XPATH, value="//select[@id='activity_id']") hide_events = Find(by=By.XPATH, value="//input[@ng-model='calendar.hideEventsWithoutBooking']") date_picker = Find(by=By.XPATH, value="//i[@ng-model='calendar.customDate']") date_picker_next = Find(by=By.XPATH, value="//i[@class='glyphicon glyphicon-chevron-right']") day_button = Find(by=By.XPATH, value="//a[@ng-click='$event.preventDefault(); calendar.setDayView()']") day_date = Find(by=By.XPATH, value="//h3[@class='col-sm-5 col-md-4 cal_header ng-binding']") day_slots = Finds(EventTicket, By.XPATH, value="//div[@class='col-xs-12 cal_day_event']") days_date_picker = Finds(by=By.XPATH, value="//span[@class='ng-binding']") time = Finds(by=By.XPATH, value="//div[@class='cal_event_tickets_avail ng-binding']") date_header = Find(by=By.XPATH, value="//span[@class='cal-header-text ng-binding']") time_slots = Finds(EventTicket, By.XPATH, value="//div[@class='col-sm-3 cal_event_time ng-binding']") close_button = Find(by=By.XPATH, value="//i[@class='close-x fa fa-times pull-right visible-md']") date_time_title = Find(by=By.XPATH, value="//span[@id='startTime']") activity_name_title = Find(by=By.XPATH, value="//span[@id='activityName']") check_in = Find(by=By.XPATH, value="//input[@data-checkincheckbox]") event_complete = Find(by=By.XPATH, value="//button[@id='markeventcomplete']") next_month = Find(by=By.XPATH, value="//button[@class='btn btn-default btn-sm pull-right uib-right']")
class MainPage(BasePage): url_path = '/' header_links = Finds( by=By.XPATH, value='//ul[@data-ng-if="baseCtrl.authSrv.isLoggedIn()"]/li/a') def get_headers_links(self): return self.header_links
class NavigationBar(BasePage): url = 'https://ci004.godo.io/dashboard.aspx' page_loader_wrapper = Find(by=By.XPATH, value="//div[@class='page-loader-wrapper']") godo_lodo = Find(by=By.XPATH, value="//a[@class = 'logo']") navigation_bar = Finds(by=By.XPATH, value="//ul[@class='nav navbar-nav navbar-right']") time_tracker = Find(by=By.XPATH, value="//div[@class = 'switch-button-background']") time_tracker_checked = Find(by=By.XPATH, value="//div[@class = 'switch-button-background checked']") menu_drop_down = Find(by=By.XPATH, value="//a[contains(@class, 'user-name')]") main_tab = Find(by=By.XPATH, value="//a[@href='#menu']") sell_tickets = Find(by=By.XPATH, value="//a//span[text()='Sell Tickets']") add_booking = Find(by=By.XPATH, value="//a[@href='/add_booking.aspx']") sell_gift_certificate = Find(by=By.XPATH, value="//a[@href = 'giftcertificate.aspx']") products = Find(by=By.XPATH, value="//a//span[text()='Products']") product_hub = Find(by=By.XPATH, value="//a[text()='Product Hub']") gift_certificates = Find(by=By.CSS_SELECTOR, value="[href = 'giftcertificate.aspx']") calendar = Find(by=By.XPATH, value="//li/a[@href='event_calendar.aspx']") profile_pic = Find(by=By.XPATH, value="//div[contains(@class, 'user-account')]/img") profile_pics = Finds(by=By.XPATH, value="//div[contains(@class, 'user-account')]/img") # Your Hubs navigation bar. sitemap = Find(by=By.XPATH, value="//i[@class='fa fa-sitemap']") activities = Find(by=By.XPATH, value="//a//span[text()='Activities']") activity_hub = Find(by=By.XPATH, value="//a[text()='Activity Hub']") addons = Find(by=By.XPATH, value="//a[text()='Add-Ons']") marketing_hub = Find(by=By.XPATH, value="//a//span[text()='Marketing and Sales']") expanded_list = Find(by=By.XPATH, value="//ul[@aria-expanded='true']") groupon = Find(by=By.XPATH, value="//a[text()='Groupon']") people = Find(by=By.XPATH, value="//a//span[text()='People']") people_hub = Find(by=By.XPATH, value="//li//a[text()='People Hub']") add_guide = Find(by=By.XPATH, value="//li//a[text()='Add a Guide/Leader']") logout = Find(by=By.XPATH, value="//ul/li/a[text()='Logout']") def scrollIntoView(self, element): self._driver.execute_script("arguments[0].scrollIntoView(true);", element)
def FindsEither(ui_type=WebElement, selectors=None, context=None): startTime = time() originalTimeout = webium.settings.implicit_timeout webium.settings.implicit_timeout = 0 notTimeout = True while notTimeout: for ident in selectors: try: itemsFound = Finds(ui_type=ui_type, by=ident[0], value=ident[1], context=context) itemsFound._search_element() if len(itemsFound._target_element) != 0: return itemsFound._target_element except: pass if time() - startTime > originalTimeout: notTimeout = False
class CustomerEventPage(BasePage): name = Find(by=By.XPATH, value="//div[@id='customereventchargeinfohtml']/div[1]/a") tickets_table = Finds( TicketsTable, by=By.XPATH, value="//h4[text()='Ticket Information']/../table[1]/tbody/tr") ticket_total = Find(by=By.XPATH, value="//td[text()='Ticket Total:']/../td[2]") addon = Find(by=By.XPATH, value="//td[text()='Add-On(s) Price:']/../td[2]") discount = Find(by=By.XPATH, value="//td[text()='Discount:']/../td[2]") gift_certificate = Find( by=By.XPATH, value="//td[text()='Gift certificate applied:']/../td[2]") booking_fee = Find(by=By.XPATH, value="//td[text()='Booking Fee']/../td[2]") tax = Find(by=By.XPATH, value="//td[contains(text(), 'Tax')]/../td[2]") grand_total = Find(by=By.XPATH, value="//td[text()='Grand Total:']/../td[2]") total_charges = Find(by=By.XPATH, value="//td[text()='Total Charges:']/../td[2]") total_due = Find(by=By.XPATH, value="//td[text()='Total Due:']/../td[2]") # Booking Charge and Reservation amount_options = Find(by=By.XPATH, value="//select[@id='chargehtml_prefill']") charge_type = Find(by=By.XPATH, value="//select[@id='charge_type']") cash_received = Find(by=By.XPATH, value="//input[@id='chargehtml_cashreceived']") check_input = Find(by=By.XPATH, value="//input[@id='charge_checknumbner']") final_button = Find(by=By.XPATH, value="//button[@id='chargehtml_dobooking']") status = Find(by=By.XPATH, value="//div[@id='statusarea']") charge_history_amount = Find(by=By.XPATH, value="//tbody/tr[1]/td[5]") charge_history_status = Find(by=By.XPATH, value="//tbody/tr[1]/td[6]") stripe = Find(by=By.XPATH, value="//iframe[@name='__privateStripeFrame4']") card_number_input = Find(by=By.XPATH, value="//input[@name='cardnumber']") card_date_input = Find(by=By.XPATH, value="//input[@name='exp-date']") card_cvc_input = Find(by=By.XPATH, value="//input[@name='cvc']") card_zip_input = Find(by=By.XPATH, value="//input[@name='postal']") def select(self, web_element, option): Select(web_element).select_by_visible_text(option) def enter_cc_info(self, card_number, card_date, card_cvc, card_zip): wait(lambda: self.stripe.is_enabled()) self._driver.switch_to.frame(self.stripe) wait(lambda: self.card_number_input.is_enabled()) self.card_number_input.clear() self.card_number_input.send_keys(card_number) self.card_date_input.send_keys(card_date) self.card_cvc_input.send_keys(card_cvc) self.card_zip_input.send_keys(card_zip) self._driver.switch_to.default_content()
class LeftNavigationBar(BasePage): sections = Finds( by=By.XPATH, value="//span[contains(@class, 'Catalog__SectionLevel1')]") subsections = Finds( by=By.XPATH, value="//span[contains(@class, 'Catalog__SectionLevel3')]/a") def get_link_by_text(self, text): return Find(by=By.LINK_TEXT, value="{}".format(text), context=self) def hover_section(self, section_name): for section in self.sections: if section.text == section_name: ActionChains(self._driver).move_to_element(section).perform() wait(lambda: len(self.subsections) > 0) break def select_subsection(self, subsection_name): self.get_link_by_text(subsection_name).click()
class GuideRequestOffPage(BasePage): url = 'https://ci004.godo.io/g_requestOff.aspx' company_drop_down = Find(by=By.XPATH, value="//select[@id='guideCompany_id']") start_date = Find(by=By.XPATH, value="//input[@id='start']") calendar_next_month = Finds(by=By.XPATH, value="//th[@class='next']") dates_calendar_start = Finds(by=By.XPATH, value="//td[@class='day']") end_date = Find(by=By.XPATH, value="//input[@id='end']") dates_calendar_end = Finds(by=By.XPATH, value="//td[@class='day']") reason_field = Find(by=By.XPATH, value="//textarea[@id='requestoff_reason']") I_aknowledge_checkbox = Find(by=By.XPATH, value="//input[@id='requestoffhtml_accept']") submit_request_button = Find(by=By.XPATH, value="//button[@id='submitrequestoff']") pop_up_notification = Find(by=By.XPATH, value="//div[@class='bootbox-body']") pop_up_OK = Find(by=By.XPATH, value="/html/body/div[5]/div/div/div[2]/button") request_entry = Finds(by=By.XPATH, value="//tr[@class='gradeX']")
def update_product_list(self): self.element_main_results = Find(by=By.CSS_SELECTOR, value="ul.s-result-list", context=self) self.elements_product_entries = Finds( by=By.CSS_SELECTOR, value="li.s-result-item.celwidget", context=self.element_main_results) self.list_product_entries = [] for product_entry in self.elements_product_entries: self.list_product_entries.append(ProductEntry(product_entry))
class AddGuidePage(BasePage): username = Find(TextField, by=By.XPATH, value="//div[label/text()='Username ']/input") password = Find(TextField, by=By.XPATH, value="//div[label/text()='Password ']/input") first_name = Find(TextField, by=By.XPATH, value="//div[label/text()='First Name ']/input") last_name = Find(TextField, by=By.XPATH, value="//div[label/text()='Last Name ']/input") email = Find(TextField, by=By.XPATH, value="//div[label/text()='Email ']/input") timezone = Find(TextField, by=By.XPATH, value="//select[@ng-model='vm.selectedTimezone']") phone_number = Find(TextField, by=By.XPATH, value="//div[label/text()='Phone Number ']/input") secondary_phone_number = Find(TextField, by=By.XPATH, value="//div[label/text()='Secondary Contact Phone ']/input") emergency_contact = Find(TextField, by=By.XPATH, value="//div[label/text()='Emergency Contact']/input") hire_date = Find(TextField, by=By.XPATH, value="//div[label/text()='Hire Date']/input") end_date = Find(TextField, by=By.XPATH, value="//div[label/text()='End Date']/input") bank_name = Find(TextField, by=By.XPATH, value="//div[label/text()='Bank Name']/input") account_type = Find(TextField, by=By.XPATH, value="//div[label/text()='Account Type']/select") bank_routing_number = Find(TextField, by=By.XPATH, value="//div[label/text()='Bank Routing Number']/input") account_number = Find(TextField, by=By.XPATH, value="//div[label/text()='Account Number']/input") pay_rate_type = Find(TextField, by=By.XPATH, value="//div[label/text()='Pay Rate Type ']/select") trained_activity = Find(by=By.XPATH, value="//div[@name='itemForm'][1]//select") trained_activity_remove = Find(by=By.XPATH, value="//div[@name='itemForm'][1]//button") save_button = Find(by=By.XPATH, value="//button[contains(text(),'Save')]") cancel_button = Find(by=By.XPATH, value="//button[text()='Cancel']") empty_space = Find(by=By.XPATH, value="(//h2)[2]") import_guide_button = Find(by=By.XPATH, value="//button[text()='Import Guide']") i_username = Find(by=By.XPATH, value="//div[@class='modal-content']//input[@placeholder='Username']") i_pay_type = Find(by=By.XPATH, value="//div[@class='modal-content']//select") i_rate = Find(by=By.XPATH, value="//div[@class='modal-content']//input[@placeholder='Enter Pay Rate']") i_close_button = Find(by=By.XPATH, value="//div[@class='modal-content']//button[text()='Close']") i_import_button = Find(by=By.XPATH, value="//div[@class='modal-content']//button[text()='Import']") error_messages = Finds(by=By.XPATH, value="//div[@class='formErrorContent']") bootstrap_alert = Find(by=By.XPATH, value="//div[contains(@class, 'alert')]/span") def verify_alert(self, wording): waiting = WebDriverWait(self._driver, 15) alert = waiting.until(EC.alert_is_present()) assert alert.text == wording alert.accept() def select(self, web_element, option): Select(web_element).select_by_visible_text(option) def get_selected_value(self, web_element): return Select(web_element).first_selected_option.text def select_trained_activity(self, activity): Select(self.trained_activity).select_by_visible_text(activity) def wait_redirection(self): old_url = self._driver.current_url wait(lambda: self._driver.current_url != old_url)