Skip to content

Commit

Permalink
test for win.isDevToolsOpen
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmanchhabra committed Sep 1, 2024
1 parent c45f2f8 commit 26b8c63
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/sanity/window-isdevtoolsopen/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>nw.Window.isDevToolsOpen fixture</title>
<script>
document.addEventListener('DOMContentLoaded', function() {
const win = nw.Window.get();
win.showDevTools(undefined, () => {
document.getElementById('isdevtoolsopen').textContent = String(win.isDevToolsOpen());
});
});
</script>
</head>
<body>
<div>
<span>win.isDevToolsOpen: </span>
<span id="isdevtoolsopen"></span>
</div>
</body>
</html>
4 changes: 4 additions & 0 deletions test/sanity/window-isdevtoolsopen/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "window-isdevtoolsopen",
"main": "index.html"
}
15 changes: 15 additions & 0 deletions test/sanity/window-isdevtoolsopen/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import platform
import time

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__)))

driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options, service_log_path="log", service_args=["--verbose"])
try:
result = driver.find_element_by_id('isdevtoolsopen').get_attribute('textContent')
assert(result == 'true')
finally:
driver.quit()

0 comments on commit 26b8c63

Please sign in to comment.