def test_aliased_as_right_angle_bracket_equals(self): xpath = to_xpath(x.descendant("p")[x.position() >= 2]) results = self.find_all(xpath) self.assertEqual(results[0].text, "Bax") self.assertEqual(results[1].get("title"), "monkey") self.assertEqual(results[2].text, "Bax") self.assertEqual(results[3].text, "Blah")
def test_checks_greater_than_or_equal(self): xpath = to_xpath(x.descendant("p")[x.position().gte(2)]) results = self.find_all(xpath) self.assertEqual(results[0].text, "Bax") self.assertEqual(results[1].get("title"), "monkey") self.assertEqual(results[2].text, "Bax") self.assertEqual(results[3].text, "Blah")
def test_checks_lesser_than(self): xpath = to_xpath(x.descendant("p")[x.position().lt(2)]) results = self.find_all(xpath) self.assertEqual(results[0].text, "Blah") self.assertEqual(results[1].get("title"), "gorilla")
def test_aliased_as_left_angle_bracket(self): xpath = to_xpath(x.descendant("p")[x.position() < 2]) results = self.find_all(xpath) self.assertEqual(results[0].text, "Blah") self.assertEqual(results[1].get("title"), "gorilla")
def test_returns_the_number_of_elements_in_the_context(self): xpath = to_xpath(x.descendant("p")[x.position() == x.last()]) results = self.find_all(xpath) self.assertEquals(inner_text(results[0]), "Bax") self.assertEquals(inner_text(results[1]), "Blah") self.assertEquals(inner_text(results[2]), "llama")
def test_takes_modulo(self): xpath = to_xpath(x.descendant("p")[x.position().mod(2) == 1]) results = self.find_all(xpath) self.assertEqual(results[0].text, "Blah") self.assertEqual(results[1].get("title"), "monkey") self.assertEqual(results[2].get("title"), "gorilla")
def test_divides(self): xpath = to_xpath(x.descendant("p")[x.position().divide(2) == 1]) results = self.find_all(xpath) self.assertEqual(results[0].text, "Bax") self.assertEqual(results[1].text, "Bax")
def test_multiplies(self): xpath = to_xpath(x.descendant("p")[x.position().multiply(3) == 3]) results = self.find_all(xpath) self.assertEqual(results[0].get("id"), "fooDiv") self.assertEqual(results[1].get("title"), "gorilla")
def test_returns_the_position_of_elements_in_the_context(self): xpath = to_xpath(x.descendant("p")[x.position() == 2]) results = self.find_all(xpath) self.assertEquals(inner_text(results[0]), "Bax") self.assertEquals(inner_text(results[1]), "Bax")
def test_subtracts(self): xpath = to_xpath(x.descendant("p")[x.position().minus(1) == 0]) results = self.find_all(xpath) self.assertEqual(results[0].get("id"), "fooDiv") self.assertEqual(results[1].get("title"), "gorilla")