Пример #1
0
class AddCVForm(Form):
    first_name = TextField(By.css("[placeholder='First Name']"))
    last_name = TextField(By.css("[placeholder='Last Name']"))
    email = TextField(By.css("[placeholder='Email']"))

    country = Dropdown(
        root=By.css(".country-wrapper"),
        by_select_locator=By.css(".arrow"),
        by_option_locator_template=By.xpath(
            "*root*//*[contains(@id,'select-box-applicantCountry')]//li[.='%s']"
        ),
    )

    city = Dropdown(
        root=By.css(".country-wrapper"),
        by_select_locator=By.css(".arrow"),
        by_option_locator_all=By.xpath(
            "*root*//*[contains(@id,'select-box-applicantCity')]//li"),
    )

    cv = RFileInput(By.css(".file-upload"))
    comment = TextArea(By.xpath(".comment-input"))

    submut = Button(By.xpath("//*[.='Submit']"))
    cancel = Button(By.xpath("//*[.='Cancel']"))
Пример #2
0
class ContactFormTwoButtons(Form):
    def __init__(self, by_locator=None):
        super(ContactFormTwoButtons, self).__init__(by_locator)

    first_name = TextField(By.id("Name"))
    last_name = TextField(By.id("LastName"))
    description = TextArea(By.id("Description"))

    submit = Button(By.xpath("//*[text()='Submit']"))
    calculate = Button(By.xpath("//*[text()='Calculate']"))

    def get_form_value(self):
        return {self.first_name.get_text(), self.last_name.get_text(), self.description.get_text()}
Пример #3
0
class EpamSite(WebSite):
    home_page = HomePage(url="/",
                         title="EPAM | Software Product Development Services")
    career_page = CareerPage(url="/careers", title="Careers")
    product_development_page = ProductDevelopmentPage(
        url="/solutions/core-engineering/product-development")
    job_listing_page = JobListingPage(
        url=
        "/careers/job-listings?sort=best_match&query=Engineer&department=Software+Test+Engineering&city=St-Petersburg&country=Russia",
        url_template="/careers/job-listings",
        title="Job Listings",
        url_check_type=CheckPageTypes.CONTAINS,
        title_check_type=CheckPageTypes.CONTAINS)
    job_description_page = None  #JobDescriptionPage(
    # url="/careers/job-listings/job.11584#apply", urlTemplate=".*/careers/job-listings/job\\.\\d*#apply",
    # urlCheckType=CheckPageTypes.MATCH)

    header_menu = Menu(by_all_options_names_locator=By.css(".tile-menu>li>a"),
                       parametrized_class=HeaderMenu)
    multiple_header_menu = Menu(by_menu_levels_locators=[
        By.css(".tile-menu>li>a"),
        By.xpath("//*[@class='tile-menu']//*[@href='/solutions']//..//li")
    ])

    line_menu = None  #JDIElements(By.css(".tile-menu>li>a"), Button)

    header_solutions_menu = None  #Menu(By.css(".tile-menu .submenu a"), HeaderSolutionsMenu)
Пример #4
0
class Cell(SelectElement):
    row_index = None
    column_index = None
    table = None
    column_num = None
    row_nom = None
    web_element = None
    column_name = None
    row_name = None
    cell_locator_template = By.xpath(".//tr[{1}]/td[{0}]")

    def __init__(self,
                 column_num,
                 row_num,
                 col_name,
                 row_name,
                 table,
                 cell_locator_template=None,
                 web_element=None,
                 column_index=None,
                 row_index=None):
        if web_element is not None:
            self.web_element = web_element
        if cell_locator_template is not None:
            self.cell_locator_template = cell_locator_template
        if column_index is not None:
            self.column_index = column_index + 1 if table.rows.has_header and table.rows.by_line_template is None else column_index
        if row_index is not None:
            self.row_index = row_index

        self.column_num = column_num
        self.row_num = row_num
        self.col_name = col_name
        self.row_name = row_name
        self.table = table

    def set_web_element(self, web_element):
        self.web_element = web_element

    def update_data(self, col_name, row_name):
        if self.column_name is None or self.column_name == "" and not (
                col_name is None or col_name == ""):
            self.column_name = col_name
        if self.row_name is None and self.row_name == "" and not (
                row_name is None or row_name == ""):
            self.row_name = row_name
        return self

    def get_text_action(self):
        return self.get().get_text()

    def get(self):
        cell = SelectElement(web_element=self.web_element) if self.web_element is not None else \
            SelectElement(
                WebDriverByUtils.fill_by_template(self.cell_locator_template, [self.column_index, self.row_index]))
        cell.init(parent=self.table, avatar=cell.avatar)
        return cell
Пример #5
0
class MetalColorPage(WebPage):
    def __init__(self, url, title):
        super(MetalColorPage, self).__init__(url=url, title=title)

    calculate_button = Button(By.id("calculate-button"))

    cb_water = CheckBoxMetalColor(
        By.xpath("//*[@id='elements-checklist']//*[text()='Water']"))

    calculate_label = Label(By.id("calculate-button"))

    nature_check_list = CheckListMetalColor(
        By.css("#elements-checklist label"))
Пример #6
0
class JobFilter(Form):
    keyword = TextField(By.css(".job-search-input"))
    category = Dropdown(root=By.css(".multi-select-department"),
                        by_select_locator=By.css(".multi-select-filter"),
                        by_option_locator_all=By.css(".blue-checkbox-label"))

    location = TreeDropdown(
        By.css(".career-location-box"),
        [By.css(".location-dropdown .optgroup"),
         By.xpath("//..//li")])

    select_button = Button(By.css(".job-search-button"))
    label = Label(By.css(".job-search-title"))
Пример #7
0
class MetalColorPage(WebPage):
    def __init__(self, url, title):
        super(MetalColorPage, self).__init__(url=url, title=title)

    calculate_button = Button(By.id("calculate-button"))

    cb_water = CheckBoxMetalColor(By.xpath("//*[@id='elements-checklist']//*[text()='Water']"))

    calculate_label = Label(By.id("calculate-button"))

    nature_check_list = CheckListMetalColor(By.css("#elements-checklist label"))

    combo_box = ComboBoxMetalColor(select_locator=By.css(".metals .caret"),
                                   options_names_locator_template=By.css(".metals li span"),
                                   value_locator=By.css(".metals input"))

    color_dropdown = Dropdown(By.css(".colors .filter-option"), By.css(".colors li span"))

    summary = Summary(By.id("summary-block"))
Пример #8
0
 def __init__(self):
     self.has_header = False
     self.element_index = ElementIndexType.nums
     self.by_headers_locator = By.xpath(".//tr/td[1]")
     self.by_default_template = By.xpath(".//tr[%s]/td")
Пример #9
0
class Table(Text):
    cache = True
    footer = list()
    by_cell_locator_template = None
    all_cells = list()
    columns = Columns()
    rows = Rows()
    by_footer_locator = By.xpath(".//tfoot/tr/th")

    def __init__(self,
                 by_table_locator=None,
                 by_column_header=None,
                 by_row_header=None,
                 by_row=None,
                 by_column=None,
                 row_start_index=None,
                 column_start_index=None,
                 by_cell_locator_template=None,
                 by_footer=None,
                 root=None):
        super(Table, self).__init__(by_locator=by_table_locator)

        self.columns.table = self
        self.rows.table = self

        if by_column is not None: self.columns.by_line_template = by_column
        if by_column_header is not None:
            self.columns.by_headers_locator = by_column_header
        if by_row is not None: self.rows.by_line_template = by_row
        if by_row_header is not None:
            self.rows.by_headers_locator = by_row_header

        if column_start_index is not None and column_start_index > -1:
            self.columns.start_index = column_start_index
        if row_start_index is not None and row_start_index > -1:
            self.rows.start_index = row_start_index

        self.by_cell_locator_template = by_cell_locator_template
        self.by_footer_locator = by_footer

    def get_text_action(self):
        return "||X||" + "|".join(self.columns.get_headers()) + "||" + "".join(
            list(
                map(
                    lambda rn: "\n||" + rn + "||" + "|".join(self.row_value(
                        rn)) + "||", self.rows.get_headers())))

    def row_value(self, row_name):
        return self.rows.get_row_value(row_name)

    def get_headers(self):
        return self.columns.get_headers()

    def is_empty(self):
        try:
            self.get_driver().implicitly_wait(0)
            row_count = self.rows.get_count(True)
            return row_count == 0
        finally:
            self.get_driver().implicitly_wait(
                JDISettings.get_current_timeout_sec())

    def column(self, val, row=None):
        if row is not None:
            column_cell = self.cell(value=val, row=row)
            col = None
            if column_cell is not None:
                num = column_cell.column_num
                col = self.columns.get_column(num)
            return col
        return self.columns.get_column(val)

    def cell(self, web_element=None, column=None, row=None, value=None):
        if None not in [web_element, column, row] and value is None:
            return self.add_cell(
                web_element,
                column.get(lambda name: self.columns.get_headers().index(name),
                           lambda num: num),
                row.get(lambda name: self.rows.get_headers().index(name),
                        lambda num: num),
                column.get(lambda name: name, lambda num: ""),
                row.get(lambda name: name, lambda num: ""))
        elif None not in [value, row] and web_element == column is None:
            row_num = self.rows.get_headers().index(
                row.name) + 1 if row.has_name() else row.num
            return list(
                filter(lambda x: x[1].get_value() == value,
                       self.rows.get_row(row_num)))[0][1]
        elif None not in [value, column] and web_element == row is None:
            col_index = self.columns.get_headers().index(
                column.name) + 1 if column.has_name() else column.num
            return list(
                filter(lambda x: x[1].get_value() == value,
                       self.columns.get_column(col_index)))[0][1]
        else:
            return None

    def add_cell(self, web_element, col_num, row_num, col_name, row_name):
        if web_element is not None:
            cells = list(
                filter(
                    lambda c: c.column_num == col_num and c.row_num == row_num,
                    self.all_cells))
            cell = cells[0] if len(cells) > 0 else None
            if cell is not None:
                cell.set_web_element(web_element)
                return cell.update_data(col_name, row_name)

            cell = Cell(web_element=web_element,
                        column_num=col_num,
                        row_num=row_num,
                        col_name=col_name,
                        row_name=row_name,
                        cell_locator_template=self.by_cell_locator_template,
                        table=self)
            if self.cache:
                self.all_cells.append(cell)
            return cell

    def row(self, val, column=None):
        if column is not None:
            row_cell = self.cell(value=val, column=column)
            return self.rows.get_row(
                row_cell.row_num) if row_cell is not None else None
        return self.rows.get_row(val)

    def get_rows(self, *col_name_values):
        if len(col_name_values) == 0:
            return ro
Пример #10
0
 def __init__(self):
     self.has_header = True
     self.element_index = ElementIndexType.nums
     self.by_headers_locator = By.xpath(".//th")
     self.by_default_template = By.xpath(".//tr/td[%s]")
Пример #11
0
class Header(Section):
    image = Image(By.xpath('//img[@src="label/Logo_Epam_Color.svg"]'))
    search_section = JDISearch()