def get_xpath(self): has_aria_label = self.matches.xpath('@aria-label', self.search_text) has_text = self.matches.xpath('.', self.search_text) has_text_or_aria_label = predicate_or(has_aria_label, has_text) return ' | '.join([ super(ButtonImpl, self).get_xpath(), self.get_input_button_xpath(), "//*[@role='button']" + has_text_or_aria_label, "//button" + predicate(has_aria_label) ])
def get_input_button_xpath(self): if self.search_text: has_value = self.matches.xpath('@value', self.search_text) has_label = self.matches.xpath('@label', self.search_text) has_aria_label = self.matches.xpath('@aria-label', self.search_text) has_title = self.matches.xpath('@title', self.search_text) has_text = \ predicate_or(has_value, has_label, has_aria_label, has_title) else: has_text = '' return "//input[@type='submit' or @type='button']" + has_text
def test_two_args(self): self.assertEqual('[a=b or c=d]', predicate_or('a=b', 'c=d'))
def test_one_arg(self): self.assertEqual('[a=b]', predicate_or('a=b'))
def test_no_args(self): self.assertEqual('', predicate_or())
def test_empty_arg_among_normal_args(self): self.assertEqual('[a=b or c=d]', predicate_or('a=b', '', 'c=d'))
def test_one_empty_arg(self): self.assertEqual('', predicate_or(''))