GithubHelp home page GithubHelp logo

pypom's Introduction

pypom's People

Contributors

bobsilverberg avatar davehunt avatar davidemoro avatar dependabot-preview[bot] avatar dependabot-support avatar greums avatar jsma avatar mozilla-github-standards avatar pyup-bot avatar rbevers avatar stephendonner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pypom's Issues

python 3.7 support

Currently, there is confirmed support only for python 2.7 and 3.6.
What about python 3.7 ?

ImportError: No module named interfaces

If you install pypom 1.1.0 you get an import error:

Type "help", "copyright", "credits" or "license" for more information.
>>> import pypom
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/pypom/__init__.py", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/pypom/page.py", line 8, in <module>
  File "build/bdist.linux-x86_64/egg/pypom/view.py", line 7, in <module>
ImportError: No module named interfaces

NameError: name 'Newsletter' is not defined

Hi,

Am using the below code provided in the documentation am getting the following error when I ran it. How to resolve this issue.

Code:

# mozilla.py
from pypom import Page, Region
from splinter import Browser

executable_path = {'executable_path':'C:/Users/tester/.webdrivers/chromedriver.exe'}

class Mozilla(Page):
    URL_TEMPLATE = 'https://www.mozilla.org/'

    @property
    def newsletter(self):
        return Newsletter(self)

    class Newsletter(Region):
        _root_locator = ('id', 'newsletter-form')
        _submit_locator = ('id', 'footer_email_submit')

        def sign_up(self):
            self.find_element(*self._submit_locator).click()

driver = Browser('chrome', **executable_path)
page = Mozilla(driver).open()
page.newsletter.sign_up()

Error:

Traceback (most recent call last):
  File "mozilla.py", line 22, in <module>
    page.newsletter.sign_up()
  File "mozilla.py", line 11, in newsletter
    return Newsletter(self)
NameError: name 'Newsletter' is not defined

implprefix DeprecationWarning with pluggy 0.7.1

Hi!

pluggy v0.7.1 has deprecated the implprefix argument:

Treeherder marks warnings as errors, which causes the following failures from PyPOM:

DeprecationWarning: Support for the `implprefix` arg is now deprecated and
will be removed in an upcoming release. Please use HookimplMarker.

(Full log: https://travis-ci.org/mozilla/treeherder/jobs/409417404#L901)

The usage within PyPOM is here:

self.pm = PluginManager('pypom', implprefix='pypom_')

We can temporarily ignore this DeprecationWarning via pytest's filterwarnings, however it would be good to fix upstream at some point.

CODE_OF_CONDUCT.md file missing

As of January 1 2019, Mozilla requires that all GitHub projects include this CODE_OF_CONDUCT.md file in the project root. The file has two parts:

  1. Required Text - All text under the headings Community Participation Guidelines and How to Report, are required, and should not be altered.
  2. Optional Text - The Project Specific Etiquette heading provides a space to speak more specifically about ways people can work effectively and inclusively together. Some examples of those can be found on the Firefox Debugger project, and Common Voice. (The optional part is commented out in the raw template file, and will not be visible until you modify and uncomment that part.)

If you have any questions about this file, or Code of Conduct policies and procedures, please see Mozilla-GitHub-Standards or email [email protected].

(Message COC001)

Unable to use PyPOM with a Selenium Driver wrapped in EventFiringWebDriver

I would like to use Selenium driver with event firing support, but PyPOM seems to fail at initialization with such configuration:

from selenium.webdriver import Chrome
from selenium.webdriver.common.by import By
from selenium.webdriver.support.events import EventFiringWebDriver, \
    AbstractEventListener

from pypom import Page


class Qwant(Page):

    _search_input_locator = (By.XPATH, '//input[@name="q"]')

    def wait_for_page_to_load(self):
        search_input = self.find_element(*self._search_input_locator)
        self.wait.until(lambda _: search_input.is_enabled())


class ExceptionListener(AbstractEventListener):
    def on_exception(self, exc, driver):
        driver.get_screenshot_as_file('exception.png')


def main():
    driver = Chrome()
    ef_driver = EventFiringWebDriver(driver, ExceptionListener())
    page = Qwant(ef_driver, base_url='https://www.qwant.com/')
    page.open()


if __name__ == '__main__':
    main()

Here's the resulting traceback:

Traceback (most recent call last):
  File "PyPOM_EventFiringWebDriver.py", line 30, in <module>
    main()
  File "PyPOM_EventFiringWebDriver.py", line 26, in main
    Qwant(ef_driver, base_url='https://www.qwant.com/')
  File "/home/damienlebourdonnec/.virtualenvs/tmp-41cf2100534a6a0/local/lib/python2.7/site-packages/pypom/page.py", line 72, in __init__
    super(Page, self).__init__(driver, timeout)
  File "/home/damienlebourdonnec/.virtualenvs/tmp-41cf2100534a6a0/local/lib/python2.7/site-packages/pypom/view.py", line 14, in __init__
    self.driver_adapter = IDriver(driver)
  File "/home/damienlebourdonnec/.virtualenvs/tmp-41cf2100534a6a0/local/lib/python2.7/site-packages/zope/component/hookable.py", line 33, in __call__
    return self.__implementation(*args, **kw)
  File "/home/damienlebourdonnec/.virtualenvs/tmp-41cf2100534a6a0/local/lib/python2.7/site-packages/zope/component/_api.py", line 156, in adapter_hook
    return sitemanager.queryAdapter(object, interface, name, default)
  File "/home/damienlebourdonnec/.virtualenvs/tmp-41cf2100534a6a0/local/lib/python2.7/site-packages/zope/interface/registry.py", line 348, in queryAdapter
    return self.adapters.queryAdapter(object, interface, name, default)
  File "/home/damienlebourdonnec/.virtualenvs/tmp-41cf2100534a6a0/local/lib/python2.7/site-packages/zope/interface/adapter.py", line 539, in _uncached_lookup
    order)
  File "/home/damienlebourdonnec/.virtualenvs/tmp-41cf2100534a6a0/local/lib/python2.7/site-packages/zope/interface/adapter.py", line 672, in _lookup
    for spec in specs[i].__sro__:
AttributeError: 'function' object has no attribute '__sro__'

Is there a trick to support EventFiringWebDriver like a normal Selenium Driver ?

Thx

Adjust 'use driver instead' DeprecationWarning's stacklevel

Hi!

Currently the deprecation warning here doesn't set a stacklevel:

warn('use driver instead', DeprecationWarning)

So results in:

    @property
    def selenium(self):
        """Backwards compatibility attribute"""
>       warn('use driver instead', DeprecationWarning)
E       DeprecationWarning: use driver instead

(For example: https://travis-ci.org/mozilla/treeherder/jobs/364313209#L736)

If the warn() also passed stacklevel=2, then it would show the caller instead, making it easier to know where to fix.

Many thanks :-)

Example in UserGuide on Repeating Regions raises error

I am following the example Repeating Regions in order to fill a repeated region in a page:

from pypom import Page, Region
from selenium.webdriver.common.by import By

class Results(Page):
    _result_locator = (By.CLASS_NAME, 'result')

    @property
    def results(self):
        results = self.find_elements(*self._result_locator)
        return [self.Result(el) for el in results]

    class Result(Region):
        _name_locator = (By.CLASS_NAME, 'name')

        @property
        def name(self):
            return self.find_element(*self._name_locator).text

but end up in this error:

def __init__(self, page, root=None):
>       super(Region, self).__init__(page.driver, page.timeout)
E       AttributeError: 'WebElement' object has no attribute 'driver'

This is because in the list comprehension that creates the individual region instances a WebElement is passed to the initializer.

Is this a documentation issue?

Using strategy as xpath is not working with region

First of all thanks for the great library to share, but I am facing the minor issue by using XPATH locator within Region.
When using XPATH locator in the Region class, over there its giving me the first element found with that XPATH throughout the page, instead it should provide me the element found with that XPATH specific to that Region.
here is what I tried
result.html

<ol>
    <li class="result">
        <span class="name">Result 1</span>
        <a href="./detail/1/">detail</a>
    </li>
    <li class="result">
        <span class="name">Result 2</span>
        <a href="./detail/2/">detail</a>
    </li>
    <li class="result">
        <span class="name">Result 3</span>
        <a href="./detail/3/">detail</a>
    </li>
    <li class="result">
        <span class="name">Result 4</span>
        <a href="./detail/4/">detail</a>
    </li>
</ol>

results_page.py

class Results(Page):
    _result_locator = (By.CLASS_NAME, 'result')

    @property
    def results(self):
        return [self.Result(self, el) for el in self.find_elements(*self._result_locator)]

    class Result(Region):
        _name_locator = **(By.XPATH, '//span')**
        _detail_locator = **(By.TAG_NAME, '//a')**

        @property
        def name(self):
            return self.find_element(*self._name_locator).text

        @property
        def detail_link(self):
            return self.find_element(*self._detail_locator).get_property("href")

main.py

result_page = Results(browser, base_url).open()

for el in (result_page.results):
    print el.name

The final output:
Result 1
Result 1
Result 1
Result 1

I tried to run the example you have shared in documentation that works great, but that is with CLASS_NAME and TAG_NAME.

Reconsider dependency on zope

Hi!

Newer minor versions of the zope.interface and zope.component dependencies now pull in many more transient dependencies than they used to:
https://github.com/mozilla/treeherder/blob/1bbc11c09b36c1aeb642fe8057647bc7c60c796d/requirements/dev.txt#L119-L184

This feels pretty heavyweight for something that doesn't seem entirely necessary. (And is adding to our dependency bot PR churn, plus on multiple occasions needed manual changes to add the hashes for sub-dependencies).

Could the zope dependencies be removed?

can't install via pip

Hey Dave!

A brief issue I noticed is that I can't install via command: pip install PyPOM

Could not find a version that satisfies the requirement PyPOM (from versions: )
No matching distribution found for PyPOM

Could you explain what's causing this?

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.