Testing MacOS Window Creation Crash Prevention in NW.js
This test suite validates the handling of window creation and crash scenarios in NW.js on macOS platforms. It specifically tests the application’s stability when creating new windows and verifies proper URL loading behavior.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
nwjs/nwJs
test/sanity/issue6113-mac-create-crash/test.py
import time
import os
import platform
import sys
if platform.system() != 'Darwin':
print('Skipped for non Mac platform')
sys.exit(0)
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from nw_util import *
chrome_options = Options()
chrome_options.add_argument("nwapp=" + os.path.dirname(os.path.abspath(__file__)))
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
driver.implicitly_wait(2)
try:
wait_window_handles(driver, 2)
handles = driver.window_handles
print(handles)
driver.switch_to_window(handles[1])
output = driver.current_url
print(output)
print('waiting for crash')
time.sleep(5)
assert driver.title == "Google"
assert("https://www.google.com/" in output)
print('There is no crash')
finally:
driver.quit()