def _given_xpath_or_css(self, selector):
xpath = selector.pop('xpath', None)
css = selector.pop('css', None)
if not (xpath or css):
return None
if xpath and css:
raise ValueError("'xpath' and 'css' cannot be combined ({})".format(selector))
how, what = [None] * 2
if xpath:
how = By.XPATH
what = xpath
elif css:
how = By.CSS_SELECTOR
what = css
if selector and not self._can_be_combined_with_xpath_or_css(selector):
raise ValueError('{} cannot be combined with other selectors {})'.format(how, selector))
return [how, what]
评论列表
文章目录