Coder Social home page Coder Social logo

pytest-pyppeteer's People

Contributors

dependabot[bot] avatar luizyao avatar tony avatar

Stargazers

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

pytest-pyppeteer's Issues

Actual not support locate element by xpath

All target function query element by selector:

For example:

    async def get_value(
        self,
        elem_name: str,
        custom_parameter: tuple = (),
        timeout: Union[float, int] = 30000,
    ) -> str:
        """Get value with an element which matches ``elem_name``.

        This method raises error if no element matched the ``elem_name``.

        :param elem_name: Element name.
        :param custom_parameter: The values used to replace "{}" in the locator.
        :param timeout: Maximum time to wait for searching element in milliseconds.
                        Defaults to 30000 (30 seconds). Pass ``0`` to disable timeout.
        :return:
        """
        await self.wait_for_element(
            elem_name, visible=True, timeout=timeout, custom_parameter=custom_parameter
        )
        locator: str = self._get_element_locator(elem_name, custom_parameter)
        value: str = await self.tab.querySelectorEval(
            locator, "(node => node.value || node.innerText)"
        )
        return value.strip()

But we can use xpath in desc file:

@classmethod
    def validate(cls, value: str) -> str:
        """Locator string must a valid css or xpath.

        :param value: a locator string
        :return:
        """
        if not isinstance(value, str):
            raise TypeError("Invalid parameter type, string required.")
        if "{}" in value:
            return cls(
                value
            )  # TODO: Custom parameters need to be dynamically populated in use
        # CSS
        try:
            cssselect.parse(value)
        except cssselect.SelectorSyntaxError:
            pass
        else:
            return cls(value)
        # XPath
        try:
            etree.XPath(value)
        except etree.XPathSyntaxError:
            pass
        else:
            return cls(value)
        raise ValueError("Invalid parameter format, neither a valid css nor xpath.")

Get attribute from element

Like target.get_value(element), i want to get attribute from an element, such as target.get_attribute(element, 'class')

Cannot popup dialog after click button

Popup a el-dialog when you click a button, but it's failed to popup now. actually element has been found successful.

When add a waiting time between found and click operator, popup successful:

        if isinstance(element, str):
            element: ElementHandle = await self.query_element(
                element,
                visible=True,
                timeout=timeout,
                custom_parameter=custom_parameter,
            )
        await asyncio.sleep(1)
        await element.click(clickCount=click_count, button=button, delay=delay)
        if dispose:
            await element.dispose()

Keep a `CHANGES` file?

Format idea, CHANGES

# Changelog

## pytest-pyppeteer  0.3.1 - unreleased

- _Insert changes/features/fixes for next release here_

### Maintenance

- #32: docs: Add project description

## pytest-pyppeteer 0.3.0 (2022-01-27)

### Packaging

- Remove `Pipfile.lock`

### What's new

- Upgrade pyppeteer 0.2.3 -> 0.2.5 (#23)

### Documentation

- Document `--slow`

## pytest-pyppeteer 0.2.1 (2020-10-16)

<!---
# vim: set filetype=markdown:
-->

Then if you like #33

[tool.poetry.urls]
# ... the rest
Changes = "https://github.com/luizyao/pytest-pyppeteer/blob/master/CHANGES"

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.