示例#1
0
 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")
示例#2
0
 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")
示例#3
0
 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")
示例#4
0
 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")
示例#5
0
 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")
示例#6
0
 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")
示例#7
0
 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")
示例#8
0
 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")
示例#9
0
 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")
示例#10
0
 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")