Skip to content

Instantly share code, notes, and snippets.

@hallvors
Created December 8, 2015 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hallvors/9061f046236c275060e1 to your computer and use it in GitHub Desktop.
Save hallvors/9061f046236c275060e1 to your computer and use it in GitHub Desktop.
Boar test example: testing the window.orientation plugin
import json
import os
import requests
import sys
import time
import unittest
from ../shared_config import do_command
class TestConsoleLogging(unittest.TestCase):
# Note: the order matters. This API reports *accumulated* messages
# during the session. Hence, the tests expected to be no-ops must be first
def test_no_orientation_getter(self):
# Open URL
data = {'url': 'data:text/html,<html><script>void(\'foo\');</script><p>Hello test</p></html>'}
response = do_command(url, "open", data)
response = do_command(url, "getPluginsResults")
data = json.loads(response.text.encode('utf-8').strip())
self.assertTrue('results' in data)
self.assertEqual(data['results']['window-orientation-usage'], False)
def test_orientation_getter(self):
# Open URL
data = {'url': 'data:text/html,<html><script>void(window.orientation);</script><p>Hello test</p></html>'}
response = do_command(url, "open", data)
response = do_command(url, "getPluginsResults")
data = json.loads(response.text.encode('utf-8').strip())
self.assertTrue('results' in data)
self.assertEqual(data['results']['window-orientation-usage'], True)
@classmethod
def tearDownClass(self):
# Destroy Tab
response = do_command(url, "destroy")
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment