pgadmin4/web/regression/feature_utils/app_starter.py
Atira Odhner fe1aec5de0 Add feature test framework, using selenium and chromedriver for UI testing.
Written by both George and Atira at Pivotal.
2017-02-22 12:41:28 +00:00

35 lines
1.1 KiB
Python

import os
import subprocess
import signal
import random
class AppStarter:
"""
Helper for starting the full pgadmin4 app and loading the page via selenium
"""
def __init__(self, driver, app_config):
self.driver = driver
self.app_config = app_config
def start_app(self):
random_server_port = str(random.randint(10000, 65535))
env = {"PGADMIN_PORT": random_server_port}
env.update(os.environ)
self.pgadmin_process = subprocess.Popen(["python", "pgAdmin4.py", "magic-portal", random_server_port],
shell=False,
preexec_fn=os.setsid,
stderr=open(os.devnull, 'w'),
env=env)
self.driver.set_window_size(1024, 1024)
print("opening browser")
self.driver.get("http://" + self.app_config.DEFAULT_SERVER + ":" + random_server_port)
def stop_app(self):
self.driver.close()
os.killpg(os.getpgid(self.pgadmin_process.pid), signal.SIGTERM)