Пример #1
0
class TestSequenceFunctions(unittest.TestCase):

    def setUp(self):
        self.driver = phantomjs.webdriver.WebDriver()
        self.driver.get("http://en.wikipedia.org/wiki/Main_Page")
        self.selector = WebdriverXPathSelector(self.driver)

    def test_wikipedia_links(self):
        navs = self.selector.select_script("return $('#p-navigation li')")
        nav_items = []
        for nav in navs:
            loader = XPathItemLoader(NavItem(), nav)
            loader.add_xpath('name', './/a')
            nav_items.append(loader.load_item())

        expected = [u'Main page', u'Contents', u'Featured content',
                    u'Current events', u'Random article', u'Donate to Wikipedia']

        for i, item in enumerate(nav_items):
            self.assertEqual(item['name'], expected[i])
Пример #2
0
 def setUp(self):
     self.driver = phantomjs.webdriver.WebDriver()
     self.driver.get("http://en.wikipedia.org/wiki/Main_Page")
     self.selector = WebdriverXPathSelector(self.driver)