Testing Nested File System Event Monitoring in NW.js
This test suite validates file system event handling and PDF output functionality in NW.js applications using Selenium WebDriver. It specifically tests the monitoring of file rename events when generating and removing PDF files through the application interface.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
nwjs/nwJs
test/sanity/issue5020-nested-loop/test.py
import time
import os
import sys
from selenium.webdriver.common.by import By
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from nw_util import *
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("nwapp=" + os.path.dirname(os.path.abspath(__file__)))
testdir = os.path.dirname(os.path.abspath(__file__))
os.chdir(testdir)
try:
os.remove('output.pdf')
except:
pass
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
try:
print(driver.current_url)
driver.find_element(By.XPATH, '//button[text()="test"]').click()
wait_for_element_id_content(driver, 'ret', 'output.pdf', 20)
time.sleep(2)
os.remove('output.pdf')
time.sleep(0.1)
result = driver.find_element_by_id('ret').get_attribute('innerHTML')
print(result)
assert("filename: output.pdf; event: rename" == result)
finally:
driver.quit()