Coder Social home page Coder Social logo

kazemat / htmlelements Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 200 KB

Html Elements is a Python framework providing easy-to-use way of interaction with web-page elements in web-page tests.

License: GNU General Public License v2.0

Python 94.34% HTML 5.66%

htmlelements's Introduction

Html Elements framework

This framework is Python implementation of good java framework HtmlElements from Yandex.

#Short description Main parent class for Web elements - Element. Input parameters:

  1. Web element - Required;
  2. Item Type - optional;
  3. Item Name - optional;
  4. An instance of logger - optional; Options 2-4 are required if you need logging operations. If it does not matter, you can leave as is. ๏Š

To search for items written decorator "find". It takes the input parameters and the function / class and interacts with the class, within which a challenge will be made. The decorator takes a named parameters to search for an item and set his name. To search you must specify the type of selector. List the names of the parameters:

  • css - CSS selector of the element
  • xpath - XPATH selector of the element
  • class_name - Name of class webelement for the selector
  • id - ID of webelement
  • name - Name of the webelement for the selector

The second parameter is optional - "element_name". Not to be confused with the "name"!

I'm not in vain mentioned that the decorator takes a function / class. He does not care which element comes. But the function must return a class member is not initialized. As a result of the decorator, the function returns an initialized class. Do not call this.

If you use a class, not a function, it is sufficient to inherit from the desired class and use within the parent. Personally, I am impressed to use the classes, since then working autocompletion in my IDE ๏Š

#Example For example, let's create a block for the search form on the page http://www.yandex.com:

from htmlelements import Page, find, TextInput, Button


class MainPage(Page):
    def __init__(self, driver):
        super(MainPage, self).__init__(driver)

    @find(css=".input__control.input__input", element_name="Search narrow")
    class SearchNarrow(TextInput):
        pass

    @find(xpath="//button[contains(@class, 'button_theme_websearch')]", element_name="search button")
    def search_button(self):
        return Button

    def search(self, text):
        self.SearchNarrow.send_keys(text, clear=True)
        self.search_button.click()

Enjoy)

htmlelements's People

Contributors

kazemat avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.