def test_create_invalid_driver(self): with self.assertRaises(TypeError): self.driver = create(driver='ie', headless=True) with self.assertRaises(TypeError): self.driver = create(driver='edge', headless=True) with self.assertRaises(TypeError): self.driver = create(driver='opera', headless=True) with self.assertRaises(TypeError): self.driver = create(driver='safari', headless=True)
def test_create_invalid_resolution(self): with self.assertRaises(TypeError): create(driver='chrome', headless=True, resolution=(1024, )) with self.assertRaises(TypeError): create(driver='chrome', headless=True, resolution=(-1024, 1024)) with self.assertRaises(TypeError): create(driver='chrome', headless=True, resolution=(None, )) with self.assertRaises(TypeError): create(driver='chrome', headless=True, resolution=('foo', 'bar'))
def test_create_resolution(self): self.driver = create(driver='chrome', headless=True, resolution=(1024, 1024)) self.assertEqual(self.driver.name, 'chrome') res = tuple(self.driver.get_window_size('current').values()) self.assertEqual((1024, 1024), res) self.driver.close()
def run(self): self.driver = driver.create(driver=self.args['driver'], headless=self.args['headless'], resolution=self.args['resolution']) self.driver.get(self.url) for task in self.tasks: name, task = factory.load_task(self.driver, task) self.execute_task(self.url, name, task) self.task_results.append(task) if self.api: self.client.update_jobs( where={'id': self.id}, data={ 'tasks_passed': len([t for t in self.task_results if t.passed]), 'log': '""' + self.log + '""' }) self.complete()
def setUp(self): self.driver = driver.create(driver='chrome', headless=True)
import sys from anna_lib.selenium.driver import create desired_driver = 'chrome' if len(sys.argv) > 1: desired_driver = sys.argv[1] driver = create(driver=desired_driver, headless=True)
def test_create_driver_firefox(self): self.driver = create(driver='firefox', headless=True) self.assertEqual(self.driver.name, 'firefox') res = tuple(self.driver.get_window_size('current').values()) self.assertEqual((1920, 1080), res) self.driver.close()
def test_create_no_driver(self): self.driver = create(headless=True) self.assertEqual(self.driver.name, 'firefox') self.driver.close()