Example #1
0
    def test_events(self):
        remote = PhantomJSRemote(
            page_settings={'userAgent': 'Blah'},
            default_headers={'Accept-Encoding': 'identity'},
        )

        yield remote.call('page.open', 'http://example.invalid')

        rpc_info = yield remote.wait_page_event('load_finished')

        self.assertEqual('fail', rpc_info['status'])
Example #2
0
    def test_events(self):
        remote = PhantomJSRemote(
            page_settings={'userAgent': 'Blah'},
            default_headers={'Accept-Encoding': 'identity'},
        )

        yield remote.call('page.open', 'http://example.invalid')

        rpc_info = yield remote.wait_page_event('load_finished')

        self.assertEqual('fail', rpc_info['status'])
Example #3
0
    def test_timeouts(self):
        remote = PhantomJSRemote()

        try:
            yield remote.wait_page_event('invalid_event', timeout=0.1)
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()

        try:
            future = remote.eval('blah', timeout=0.1)
            remote._rpc_reply_map.clear()
            yield future
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()

        try:
            future = remote.set('blah', 123, timeout=0.1)
            remote._rpc_reply_map.clear()
            yield future
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()

        try:
            future = remote.call('blah', timeout=0.1)
            remote._rpc_reply_map.clear()
            yield future
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()
Example #4
0
    def test_rpc(self):
        remote = PhantomJSRemote()

        result = yield remote.call('debugEcho', 'hello!')

        self.assertEqual('hello!', result)

        yield remote.eval('var myvalue;')
        yield remote.set('myvalue', 123)

        result = yield remote.eval('myvalue')

        self.assertEqual(123, result)

        yield remote.set('myvalue', 'abc')

        result = yield remote.eval('myvalue')

        self.assertEqual('abc', result)
Example #5
0
    def test_rpc(self):
        remote = PhantomJSRemote()

        result = yield remote.call('debugEcho', 'hello!')

        self.assertEqual('hello!', result)

        yield remote.eval('var myvalue;')
        yield remote.set('myvalue', 123)

        result = yield remote.eval('myvalue')

        self.assertEqual(123, result)

        yield remote.set('myvalue', 'abc')

        result = yield remote.eval('myvalue')

        self.assertEqual('abc', result)
Example #6
0
    def test_timeouts(self):
        remote = PhantomJSRemote()

        try:
            yield remote.wait_page_event('invalid_event', timeout=0.1)
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()

        try:
            future = remote.eval('blah', timeout=0.1)
            remote._rpc_reply_map.clear()
            yield future
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()

        try:
            future = remote.set('blah', 123, timeout=0.1)
            remote._rpc_reply_map.clear()
            yield future
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()

        try:
            future = remote.call('blah', timeout=0.1)
            remote._rpc_reply_map.clear()
            yield future
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()
Example #7
0
    def test_page_reset(self):
        remote = PhantomJSRemote()

        yield remote.call('resetPage')
Example #8
0
    def test_page_reset(self):
        remote = PhantomJSRemote()

        yield remote.call('resetPage')