def __init__(self, browser, **kwargs):
        """
        Generate a query over a browser.

        Args:
            browser (selenium.webdriver): A Selenium-controlled browser.

        Keyword Args:
            css (str): A CSS selector.
            xpath (str): An XPath selector.

        Returns:
            BrowserQuery

        Raises:
            TypeError: The query must be passed either a CSS or XPath selector, but not both.
        """
        if len(kwargs) > 1:
            raise TypeError('BrowserQuery() takes at most 1 keyword argument.')

        if not kwargs:
            raise TypeError('Must pass a query keyword argument to BrowserQuery().')

        query_name, query_value = list(kwargs.items())[0]

        if query_name not in QUERY_TYPES:
            raise TypeError(u'{} is not a supported query type for BrowserQuery()'.format(query_name))

        def query_fn():  # pylint: disable=missing-docstring
            return getattr(browser, QUERY_TYPES[query_name])(query_value)

        super(BrowserQuery, self).__init__(
            query_fn,
            desc=u"BrowserQuery({}={!r})".format(query_name, query_value),
        )
        self.browser = browser
def __init__ ( self , browser , ** kwargs ) : if len ( kwargs ) > 1 : raise TypeError ( 'BrowserQuery() takes at most 1 keyword argument.' ) if not kwargs : raise TypeError ( 'Must pass a query keyword argument to BrowserQuery().' ) query_name , query_value = list ( kwargs . items ( ) ) [ 0 ] if query_name not in QUERY_TYPES : raise TypeError ( u'{} is not a supported query type for BrowserQuery()' . format ( query_name ) ) def query_fn ( ) : return getattr ( browser , QUERY_TYPES [ query_name ] ) ( query_value ) super ( BrowserQuery , self ) . __init__ ( query_fn , desc = u"BrowserQuery({}={!r})" . format ( query_name , query_value ) , ) self . browser = browser
Generate a query over a browser.

        Args:
            browser (selenium.webdriver): A Selenium-controlled browser.

        Keyword Args:
            css (str): A CSS selector.
            xpath (str): An XPath selector.

        Returns:
            BrowserQuery

        Raises:
            TypeError: The query must be passed either a CSS or XPath selector, but not both.