Read firefox path from environment variable for performance test

This commit is contained in:
Shing Lyu 2017-01-10 16:48:54 +08:00
parent 9d320d5a34
commit d8501badc0
2 changed files with 33 additions and 3 deletions

View file

@ -6,13 +6,22 @@
from contextlib import contextmanager
import json
import os
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
import sys
@contextmanager
def create_gecko_session():
firefox_binary = "./firefox/firefox/firefox"
try:
firefox_binary = os.environ['FIREFOX_BIN']
except KeyError:
print("+=============================================================+")
print("| You must set the path to your firefox binary to FIREFOX_BIN |")
print("+=============================================================+")
sys.exit()
driver = webdriver.Firefox(firefox_binary=firefox_binary)
yield driver
# driver.quit() gives an "'NoneType' object has no attribute 'path'" error.
@ -90,6 +99,7 @@ def run_gecko_test(testcase, timeout):
return [timings]
if __name__ == '__main__':
# Just for manual testing
from pprint import pprint