Initial commit: Server configurations and license management

This commit is contained in:
2025-12-10 10:18:41 -05:00
commit 93ad1a72c2
29 changed files with 4647 additions and 0 deletions

50
temp/find-part.js Normal file
View File

@@ -0,0 +1,50 @@
import auth from '../tools/siemens-auth.js';
const browser = await auth.getBrowser();
const page = await browser.newPage();
await auth.loadCookies(page);
// Navigate to annotated.html and find Part class
await page.goto('https://docs.sw.siemens.com/documentation/external/PL20200522120320484/en-US/nx_open_python_ref/nx/1980/nx_open_python_ref/en-US/nxopen_python_ref/annotated.html', { waitUntil: 'networkidle2' });
await new Promise(r => setTimeout(r, 3000));
// Find Part class links
const partLinks = await page.evaluate(() => {
const links = Array.from(document.querySelectorAll('a.el'));
return links
.filter(a => a.innerText && (a.innerText === 'Part' || a.innerText === 'NXOpen::Part'))
.map(a => ({ text: a.innerText.trim(), href: a.href.split('/').pop() }));
});
console.log('Part links found:', partLinks);
// Also search for BasePart
const basePartLinks = await page.evaluate(() => {
const links = Array.from(document.querySelectorAll('a.el'));
return links
.filter(a => a.innerText && a.innerText.includes('BasePart'))
.map(a => ({ text: a.innerText.trim(), href: a.href.split('/').pop() }))
.slice(0, 5);
});
console.log('BasePart links:', basePartLinks);
// Navigate to Part if found
if (partLinks.length > 0) {
const partUrl = 'https://docs.sw.siemens.com/documentation/external/PL20200522120320484/en-US/nx_open_python_ref/nx/1980/nx_open_python_ref/en-US/nxopen_python_ref/' + partLinks[0].href;
console.log('\nNavigating to:', partUrl);
await page.goto(partUrl, { waitUntil: 'networkidle2' });
await new Promise(r => setTimeout(r, 3000));
const content = await page.evaluate(() => ({
title: document.title,
hasError: document.body.innerText.includes('Access Denied'),
preview: document.body.innerText.substring(0, 2000)
}));
console.log('Title:', content.title);
console.log('Has error:', content.hasError);
console.log('Content:', content.preview);
}
await auth.closeBrowser();

BIN
temp/python-ref-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

BIN
temp/python-ref-3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

336
temp/server.js Normal file
View File

@@ -0,0 +1,336 @@
#!/usr/bin/env node
// MCP Server - exposes dalidou tools to Claude Code on Windows
import "dotenv/config";
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";
import weather from "../tools/weather.js";
import gitea from "../tools/gitea.js";
import siemensDocs from "../tools/siemens-docs.js";
const server = new Server(
{
name: "dalidou-assistant",
version: "1.3.0",
},
{
capabilities: {
tools: {},
},
}
);
// List available tools
server.setRequestHandler(ListToolsRequestSchema, async () => {
return {
tools: [
// Weather tools
{
name: "get_current_weather",
description: "Get current weather conditions in Rouyn-Noranda (temperature, wind, conditions)",
inputSchema: {
type: "object",
properties: {},
required: []
}
},
{
name: "get_hourly_forecast",
description: "Get hourly weather forecast for planning activities",
inputSchema: {
type: "object",
properties: {
days: { type: "number", description: "Days to forecast (1-7)" }
}
}
},
{
name: "get_daily_forecast",
description: "Get daily weather forecast (highs, lows, conditions)",
inputSchema: {
type: "object",
properties: {
days: { type: "number", description: "Days to forecast (1-14)" }
}
}
},
{
name: "find_best_activity_windows",
description: "Find best time windows for outdoor activities based on weather",
inputSchema: {
type: "object",
properties: {
activity: {
type: "string",
description: "Activity: skiing, cross-country-skiing, hiking, mushroom-hunting"
},
days: { type: "number", description: "Days to search (1-7)" }
},
required: ["activity"]
}
},
{
name: "check_skiing_conditions",
description: "Check if current conditions are good for cross-country skiing",
inputSchema: {
type: "object",
properties: {}
}
},
// Gitea tools
{
name: "get_today_commits",
description: "Get all git commits made today from Gitea",
inputSchema: {
type: "object",
properties: {}
}
},
{
name: "get_recent_activity",
description: "Get recent git activity across all Gitea repos",
inputSchema: {
type: "object",
properties: {
days: { type: "number", description: "Days of history (default 7)" }
}
}
},
{
name: "list_repos",
description: "List all repositories on Gitea",
inputSchema: {
type: "object",
properties: {}
}
},
// Siemens Documentation tools
{
name: "siemens_docs_list",
description: "List available Siemens documentation categories, NX Open class IDs, and usage info",
inputSchema: {
type: "object",
properties: {}
}
},
{
name: "siemens_docs_search",
description: "Search Siemens Support Center documentation for a specific topic",
inputSchema: {
type: "object",
properties: {
query: {
type: "string",
description: "Search query (e.g., 'NXOpen Body.GetFaces', 'sketch constraints')"
},
product: {
type: "string",
description: "Product to search: nx, teamcenter, simcenter, nastran (default: nx)"
}
},
required: ["query"]
}
},
{
name: "siemens_docs_fetch",
description: "Fetch a specific Siemens documentation page by URL",
inputSchema: {
type: "object",
properties: {
url: {
type: "string",
description: "Full URL of the documentation page to fetch"
}
},
required: ["url"]
}
},
{
name: "siemens_auth_status",
description: "Check Siemens Support Center authentication status",
inputSchema: {
type: "object",
properties: {}
}
},
{
name: "siemens_login",
description: "Login to Siemens Support Center (use if session expired)",
inputSchema: {
type: "object",
properties: {}
}
},
// NX Open Python Reference tools
{
name: "nxopen_get_class",
description: "Get NX Open Python class documentation. Known classes: Session, Part, BasePart, PdmSession, CaeSession",
inputSchema: {
type: "object",
properties: {
className: {
type: "string",
description: "Class name (e.g., 'Session', 'Part', 'BasePart')"
}
},
required: ["className"]
}
},
{
name: "nxopen_get_index",
description: "Get NX Open Python Reference index pages (class list, functions, hierarchy)",
inputSchema: {
type: "object",
properties: {
indexType: {
type: "string",
description: "Index type: classes, annotated, hierarchy, functions, main (default: classes)"
}
}
}
},
{
name: "nxopen_fetch_page",
description: "Fetch any NX Open Python Reference page by page ID (e.g., 'a03318.html' for Session)",
inputSchema: {
type: "object",
properties: {
pagePath: {
type: "string",
description: "Page path (e.g., 'a03318.html', 'classes.html', 'functions_s.html')"
}
},
required: ["pagePath"]
}
}
]
};
});
// Handle tool calls
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
try {
let result;
switch (name) {
// Weather tools
case "get_current_weather":
result = await weather.getCurrentWeather();
break;
case "get_hourly_forecast":
result = await weather.getHourlyForecast(args?.days || 2);
break;
case "get_daily_forecast":
result = await weather.getDailyForecast(args?.days || 7);
break;
case "find_best_activity_windows":
result = await weather.findBestTimeWindows(args.activity, args?.days || 2);
break;
case "check_skiing_conditions":
const current = await weather.getCurrentWeather();
const skiCheck = weather.isGoodForSkiing(current);
result = {
current_weather: current,
good_for_skiing: skiCheck.good,
assessment: skiCheck.reasons
};
break;
// Gitea tools
case "get_today_commits":
result = await gitea.getAllTodayCommits();
break;
case "get_recent_activity":
result = await gitea.getRepoActivity(args?.days || 7);
break;
case "list_repos":
result = await gitea.listRepos();
break;
// Siemens Documentation tools
case "siemens_docs_list":
result = await siemensDocs.listAvailableDocs();
break;
case "siemens_docs_search":
result = await siemensDocs.searchDocs(args.query, args.product || "nx");
break;
case "siemens_docs_fetch":
result = await siemensDocs.fetchDocPage(args.url);
break;
case "siemens_auth_status":
result = await siemensDocs.checkAuthStatus();
break;
case "siemens_login":
result = await siemensDocs.performLogin();
break;
// NX Open Python Reference tools
case "nxopen_get_class":
result = await siemensDocs.fetchNXOpenClass(args.className);
break;
case "nxopen_get_index":
result = await siemensDocs.getNXOpenIndex(args?.indexType || "classes");
break;
case "nxopen_fetch_page":
result = await siemensDocs.fetchNXOpenPythonRef(args.pagePath);
break;
default:
return {
content: [{ type: "text", text: `Unknown tool: ${name}` }],
isError: true
};
}
return {
content: [{
type: "text",
text: typeof result === "string" ? result : JSON.stringify(result, null, 2)
}]
};
} catch (error) {
return {
content: [{ type: "text", text: `Error: ${error.message}` }],
isError: true
};
}
});
// Cleanup on exit
process.on("SIGINT", async () => {
await siemensDocs.closeBrowser();
process.exit(0);
});
process.on("SIGTERM", async () => {
await siemensDocs.closeBrowser();
process.exit(0);
});
// Start server
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
console.error("Dalidou MCP Server v1.3.0 running on stdio (with NX Open Python Reference)");
}
main().catch(console.error);

110
temp/test-classes.js Normal file
View File

@@ -0,0 +1,110 @@
import auth from '../tools/siemens-auth.js';
console.log('=== Testing NX Open Class Documentation Access ===\n');
const browser = await auth.getBrowser();
const page = await browser.newPage();
await page.setViewport({ width: 1400, height: 900 });
await auth.loadCookies(page);
// Navigate to the hierarchy page (which we know works)
const hierarchyUrl = 'https://docs.sw.siemens.com/documentation/external/PL20200522120320484/en-US/nx_open_python_ref/nx/1980/nx_open_python_ref/en-US/nxopen_python_ref/a00006.html';
console.log('Loading hierarchy page:', hierarchyUrl);
await page.goto(hierarchyUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
// Handle cookie popup if present
const cookieBtn = await page.evaluateHandle(() => {
const btns = Array.from(document.querySelectorAll('button'));
return btns.find(b => b.innerText && b.innerText.includes('Accept All Cookies'));
});
if (cookieBtn && cookieBtn.asElement()) {
await cookieBtn.asElement().click();
await new Promise(r => setTimeout(r, 2000));
}
// Get the page title and content
const pageInfo = await page.evaluate(() => {
return {
title: document.title,
h1: document.querySelector('h1')?.innerText || 'No H1',
bodyText: document.body.innerText.substring(0, 1500)
};
});
console.log('\nPage Title:', pageInfo.title);
console.log('H1:', pageInfo.h1);
console.log('\nPage content preview:');
console.log(pageInfo.bodyText);
// Find all class links on the hierarchy page
const classLinks = await page.evaluate(() => {
const links = Array.from(document.querySelectorAll('a'));
return links
.filter(a => a.href && a.href.includes('class') && a.innerText)
.map(a => ({ text: a.innerText.trim(), href: a.href }))
.filter(l => l.text.length > 0 && l.text.length < 100)
.slice(0, 20);
});
console.log('\n=== Found class links:', classLinks.length);
classLinks.forEach(l => console.log(` - ${l.text}: ${l.href.split('/').pop()}`));
// Try clicking on a class link (NXOpen.Session if available)
const sessionLink = classLinks.find(l => l.text.includes('Session') || l.text.includes('NXOpen'));
if (sessionLink) {
console.log('\n=== Testing click on:', sessionLink.text);
// Click the link
await page.evaluate((href) => {
const link = document.querySelector(`a[href="${href}"]`) ||
Array.from(document.querySelectorAll('a')).find(a => a.href === href);
if (link) link.click();
}, sessionLink.href);
await new Promise(r => setTimeout(r, 5000));
// Check the new page
const classPageInfo = await page.evaluate(() => {
return {
url: window.location.href,
title: document.title,
h1: document.querySelector('h1')?.innerText || 'No H1',
hasContent: document.body.innerText.length > 500,
bodyPreview: document.body.innerText.substring(0, 1000)
};
});
console.log('\nClass page URL:', classPageInfo.url);
console.log('Class page title:', classPageInfo.title);
console.log('Class page H1:', classPageInfo.h1);
console.log('Has substantial content:', classPageInfo.hasContent);
console.log('\nContent preview:');
console.log(classPageInfo.bodyPreview);
await page.screenshot({ path: '/tmp/class-page.png' });
console.log('\nScreenshot saved to /tmp/class-page.png');
}
// Test direct navigation to a known class URL via the iframe
console.log('\n=== Testing direct class URL within iframe context ===');
const sessionClassUrl = 'https://docs.sw.siemens.com/documentation/external/PL20200522120320484/en-US/nx_open_python_ref/nx/1980/nx_open_python_ref/en-US/nxopen_python_ref/classNXOpen_1_1Session.html';
await page.goto(sessionClassUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
const directAccessInfo = await page.evaluate(() => {
return {
url: window.location.href,
title: document.title,
bodyText: document.body.innerText.substring(0, 1500),
hasError: document.body.innerText.includes('Access Denied') || document.body.innerText.includes('Error')
};
});
console.log('\nDirect URL access result:');
console.log('Title:', directAccessInfo.title);
console.log('Has error:', directAccessInfo.hasError);
console.log('Content:', directAccessInfo.bodyText);
await auth.closeBrowser();
console.log('\n=== Test Complete ===');

158
temp/test-classes2.js Normal file
View File

@@ -0,0 +1,158 @@
import auth from '../tools/siemens-auth.js';
console.log('=== Testing NX Open Class Documentation Navigation ===\n');
const browser = await auth.getBrowser();
const page = await browser.newPage();
await page.setViewport({ width: 1400, height: 900 });
await auth.loadCookies(page);
// Start from the main index page
const baseUrl = 'https://docs.sw.siemens.com/documentation/external/PL20200522120320484/en-US/nx_open_python_ref/nx/1980/nx_open_python_ref/en-US/nxopen_python_ref/';
// Navigate to Class Index
const classIndexUrl = baseUrl + 'classes.html';
console.log('Loading Class Index:', classIndexUrl);
await page.goto(classIndexUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
// Handle cookie popup if present
const cookieBtn = await page.evaluateHandle(() => {
const btns = Array.from(document.querySelectorAll('button'));
return btns.find(b => b.innerText && b.innerText.includes('Accept All Cookies'));
});
if (cookieBtn && cookieBtn.asElement()) {
await cookieBtn.asElement().click();
await new Promise(r => setTimeout(r, 2000));
}
const classIndexInfo = await page.evaluate(() => {
return {
title: document.title,
url: window.location.href,
bodyPreview: document.body.innerText.substring(0, 2000)
};
});
console.log('Title:', classIndexInfo.title);
console.log('URL:', classIndexInfo.url);
console.log('\nContent preview:');
console.log(classIndexInfo.bodyPreview);
// Find all class links
const allClassLinks = await page.evaluate(() => {
const links = Array.from(document.querySelectorAll('a'));
return links
.filter(a => a.href && (a.href.includes('class') || a.href.includes('struct')))
.map(a => ({ text: a.innerText.trim(), href: a.href }))
.filter(l => l.text.length > 0)
.slice(0, 50);
});
console.log('\n=== Class links found:', allClassLinks.length);
allClassLinks.slice(0, 20).forEach(l => console.log(` - ${l.text}`));
// Try clicking on the Session class if found
const sessionLink = allClassLinks.find(l => l.text === 'Session' || l.text.includes('Session'));
if (sessionLink) {
console.log('\n=== Clicking on Session class ===');
console.log('Link:', sessionLink.href);
await page.goto(sessionLink.href, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
const sessionInfo = await page.evaluate(() => {
return {
title: document.title,
url: window.location.href,
hasError: document.body.innerText.includes('Access Denied') || document.body.innerText.includes('Error'),
bodyPreview: document.body.innerText.substring(0, 2000)
};
});
console.log('\nSession class page:');
console.log('Title:', sessionInfo.title);
console.log('URL:', sessionInfo.url);
console.log('Has error:', sessionInfo.hasError);
console.log('\nContent:');
console.log(sessionInfo.bodyPreview);
await page.screenshot({ path: '/tmp/session-class.png' });
} else {
// Try any class link
if (allClassLinks.length > 0) {
console.log('\n=== Clicking on first class:', allClassLinks[0].text);
await page.goto(allClassLinks[0].href, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
const classInfo = await page.evaluate(() => {
return {
title: document.title,
url: window.location.href,
hasError: document.body.innerText.includes('Access Denied') || document.body.innerText.includes('Error'),
bodyPreview: document.body.innerText.substring(0, 2000)
};
});
console.log('Title:', classInfo.title);
console.log('Has error:', classInfo.hasError);
console.log('Content:', classInfo.bodyPreview);
}
}
// Test accessing through the Doxygen wrapper URL
console.log('\n=== Testing via Siemens docs portal wrapper ===');
const portalUrl = 'https://docs.sw.siemens.com/en-US/doc/209349590/PL20200522120320484.nxopen_python_ref?audience=external';
await page.goto(portalUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 5000));
// Handle any cookie popup
const cookieBtn2 = await page.evaluateHandle(() => {
const btns = Array.from(document.querySelectorAll('button'));
return btns.find(b => b.innerText && b.innerText.includes('Accept All Cookies'));
});
if (cookieBtn2 && cookieBtn2.asElement()) {
await cookieBtn2.asElement().click();
await new Promise(r => setTimeout(r, 2000));
}
// Look for iframe
const frames = page.frames();
console.log('Frames found:', frames.length);
for (const frame of frames) {
const frameUrl = frame.url();
if (frameUrl.includes('nxopen_python_ref')) {
console.log('Found doc frame:', frameUrl);
// Try to find and click on Classes menu
const classesMenu = await frame.evaluateHandle(() => {
const elements = Array.from(document.querySelectorAll('a, button, span'));
return elements.find(e => e.innerText && e.innerText.trim() === 'Classes');
});
if (classesMenu && classesMenu.asElement()) {
console.log('Found Classes menu, clicking...');
await classesMenu.asElement().click();
await new Promise(r => setTimeout(r, 2000));
// Check for dropdown
const dropdown = await frame.evaluate(() => {
const links = Array.from(document.querySelectorAll('a'));
return links
.filter(a => a.innerText && a.offsetParent !== null)
.map(a => ({ text: a.innerText.trim(), href: a.href }))
.filter(l => l.href.includes('class'))
.slice(0, 10);
});
console.log('Dropdown class links:', dropdown);
}
break;
}
}
await page.screenshot({ path: '/tmp/portal-view.png' });
await auth.closeBrowser();
console.log('\n=== Test Complete ===');

126
temp/test-classes3.js Normal file
View File

@@ -0,0 +1,126 @@
import auth from '../tools/siemens-auth.js';
console.log('=== Testing NX Open Class Documentation - Finding Session Class ===\n');
const browser = await auth.getBrowser();
const page = await browser.newPage();
await page.setViewport({ width: 1400, height: 900 });
await auth.loadCookies(page);
// Navigate to S section of class index
const baseUrl = 'https://docs.sw.siemens.com/documentation/external/PL20200522120320484/en-US/nx_open_python_ref/nx/1980/nx_open_python_ref/en-US/nxopen_python_ref/';
// First get the classes.html and look for actual clickable class links
const classIndexUrl = baseUrl + 'classes.html';
console.log('Loading Class Index:', classIndexUrl);
await page.goto(classIndexUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
// Handle cookie popup if present
const cookieBtn = await page.evaluateHandle(() => {
const btns = Array.from(document.querySelectorAll('button'));
return btns.find(b => b.innerText && b.innerText.includes('Accept All Cookies'));
});
if (cookieBtn && cookieBtn.asElement()) {
await cookieBtn.asElement().click();
await new Promise(r => setTimeout(r, 2000));
}
// Find actual class links (not letter index links)
const classLinks = await page.evaluate(() => {
const links = Array.from(document.querySelectorAll('a'));
return links
.map(a => ({ text: a.innerText.trim(), href: a.href }))
.filter(l => l.href.includes('class') && l.href.endsWith('.html') && !l.href.includes('classes.html'))
.slice(0, 100);
});
console.log('Found actual class links:', classLinks.length);
classLinks.slice(0, 20).forEach(l => console.log(` - ${l.text}: ${l.href.split('/').pop()}`));
// Try to find Session class link
const sessionLink = classLinks.find(l => l.text.includes('Session') && !l.text.includes('SessionBuilder'));
console.log('\nSession link found:', sessionLink);
if (sessionLink) {
console.log('\n=== Navigating to Session class ===');
await page.goto(sessionLink.href, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
const sessionPage = await page.evaluate(() => {
return {
title: document.title,
url: window.location.href,
hasError: document.body.innerText.includes('Access Denied') ||
document.body.innerText.includes('<Error>') ||
document.body.innerText.includes('AccessDenied'),
bodyText: document.body.innerText.substring(0, 3000)
};
});
console.log('Session page title:', sessionPage.title);
console.log('URL:', sessionPage.url);
console.log('Has error:', sessionPage.hasError);
console.log('\n--- Content ---');
console.log(sessionPage.bodyText);
await page.screenshot({ path: '/tmp/session-class.png' });
}
// If no session link directly, navigate to the NXOpen namespace and look there
if (!sessionLink || classLinks.length === 0) {
console.log('\n=== Trying NXOpen namespace page ===');
const nxopenUrl = baseUrl + 'namespaceNXOpen.html';
await page.goto(nxopenUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
const nxopenPage = await page.evaluate(() => {
return {
title: document.title,
hasError: document.body.innerText.includes('Access Denied'),
bodyText: document.body.innerText.substring(0, 3000)
};
});
console.log('NXOpen namespace page:');
console.log('Title:', nxopenPage.title);
console.log('Has error:', nxopenPage.hasError);
console.log(nxopenPage.bodyText);
// Look for Session class link
const sessionInNs = await page.evaluate(() => {
const links = Array.from(document.querySelectorAll('a'));
return links
.filter(a => a.innerText.includes('Session'))
.map(a => ({ text: a.innerText.trim(), href: a.href }))
.slice(0, 10);
});
console.log('\nSession links in NXOpen namespace:', sessionInNs);
}
// Try the annotated page
console.log('\n=== Testing annotated.html ===');
const annotatedUrl = baseUrl + 'annotated.html';
await page.goto(annotatedUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
const annotatedPage = await page.evaluate(() => {
return {
title: document.title,
hasError: document.body.innerText.includes('Access Denied'),
bodyText: document.body.innerText.substring(0, 2000),
links: Array.from(document.querySelectorAll('a'))
.filter(a => a.href.includes('class') && a.innerText.includes('Session'))
.map(a => ({ text: a.innerText.trim(), href: a.href }))
};
});
console.log('Annotated page title:', annotatedPage.title);
console.log('Has error:', annotatedPage.hasError);
console.log('Session links:', annotatedPage.links);
console.log('\nContent preview:');
console.log(annotatedPage.bodyText);
await auth.closeBrowser();
console.log('\n=== Test Complete ===');

166
temp/test-classes4.js Normal file
View File

@@ -0,0 +1,166 @@
import auth from '../tools/siemens-auth.js';
console.log('=== Testing NX Open Class List Navigation ===\n');
const browser = await auth.getBrowser();
const page = await browser.newPage();
await page.setViewport({ width: 1400, height: 900 });
await auth.loadCookies(page);
const baseUrl = 'https://docs.sw.siemens.com/documentation/external/PL20200522120320484/en-US/nx_open_python_ref/nx/1980/nx_open_python_ref/en-US/nxopen_python_ref/';
// Navigate to annotated.html (Class List)
const annotatedUrl = baseUrl + 'annotated.html';
console.log('Loading:', annotatedUrl);
await page.goto(annotatedUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
// Handle cookie popup
const cookieBtn = await page.evaluateHandle(() => {
const btns = Array.from(document.querySelectorAll('button'));
return btns.find(b => b.innerText && b.innerText.includes('Accept All Cookies'));
});
if (cookieBtn && cookieBtn.asElement()) {
await cookieBtn.asElement().click();
await new Promise(r => setTimeout(r, 2000));
}
// Try to expand the tree view by clicking on detail level indicators
console.log('\n=== Expanding tree view ===');
// Look for expand arrows or [+] buttons
const expandButtons = await page.evaluate(() => {
// Look for various expand mechanisms
const results = {
arrows: [],
plusSigns: [],
togglers: []
};
// Doxygen typically uses arrow images or [+] text
const imgs = Array.from(document.querySelectorAll('img'));
imgs.forEach(img => {
if (img.alt && (img.alt.includes('arrow') || img.alt.includes('expand'))) {
results.arrows.push({ src: img.src, alt: img.alt });
}
});
// Look for tree toggle elements
const spans = Array.from(document.querySelectorAll('span'));
spans.forEach(s => {
if (s.className && (s.className.includes('arrow') || s.className.includes('toggle'))) {
results.togglers.push(s.className);
}
});
// Look for any clickable elements near NXOpen
const allElements = Array.from(document.querySelectorAll('*'));
const nxopenElements = allElements.filter(e =>
e.innerText && e.innerText.includes('NXOpen') && e.innerText.length < 50
);
return {
...results,
nxopenElements: nxopenElements.map(e => ({
tag: e.tagName,
text: e.innerText.trim(),
className: e.className
})),
html: document.body.innerHTML.substring(0, 5000)
};
});
console.log('Expand buttons found:', expandButtons.arrows.length, 'arrows,', expandButtons.togglers.length, 'togglers');
console.log('NXOpen elements:', expandButtons.nxopenElements);
// Try clicking on the NXOpen row to expand it
const clickResult = await page.evaluate(() => {
// Look for expandable row
const rows = Array.from(document.querySelectorAll('tr'));
for (const row of rows) {
if (row.innerText && row.innerText.includes('NXOpen')) {
// Find the arrow/expand control in this row
const arrow = row.querySelector('span.arrow') || row.querySelector('img') || row.querySelector('[onclick]');
if (arrow) {
arrow.click();
return 'Clicked arrow in NXOpen row';
}
// Try clicking the row itself
row.click();
return 'Clicked NXOpen row';
}
}
// Try the detail level links
const links = Array.from(document.querySelectorAll('a'));
const detailLink = links.find(a => a.innerText && a.innerText.includes('3'));
if (detailLink) {
detailLink.click();
return 'Clicked detail level 3';
}
return 'No expandable element found';
});
console.log('Click result:', clickResult);
await new Promise(r => setTimeout(r, 2000));
// Get current state
const pageContent = await page.evaluate(() => {
return {
title: document.title,
text: document.body.innerText.substring(0, 4000),
allLinks: Array.from(document.querySelectorAll('a'))
.filter(a => a.href && a.href.includes('.html'))
.map(a => ({ text: a.innerText.trim().substring(0, 50), href: a.href.split('/').pop() }))
.slice(0, 50)
};
});
console.log('\n=== Page content after click ===');
console.log(pageContent.text);
console.log('\n=== Links found ===');
pageContent.allLinks.forEach(l => console.log(` - ${l.text}: ${l.href}`));
// Try the search functionality
console.log('\n=== Testing search functionality ===');
const searchUrl = baseUrl + 'search.html';
await page.goto(searchUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 2000));
const searchPage = await page.evaluate(() => {
return {
title: document.title,
hasError: document.body.innerText.includes('Access Denied'),
hasSearchBox: !!document.querySelector('input[type="search"]') || !!document.querySelector('#MSearchBox'),
content: document.body.innerText.substring(0, 1000)
};
});
console.log('Search page title:', searchPage.title);
console.log('Has error:', searchPage.hasError);
console.log('Has search box:', searchPage.hasSearchBox);
console.log('Content:', searchPage.content);
// Try to access functions list
console.log('\n=== Testing functions list ===');
const functionsUrl = baseUrl + 'functions.html';
await page.goto(functionsUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 2000));
const functionsPage = await page.evaluate(() => {
return {
title: document.title,
hasError: document.body.innerText.includes('Access Denied'),
content: document.body.innerText.substring(0, 2000)
};
});
console.log('Functions page title:', functionsPage.title);
console.log('Has error:', functionsPage.hasError);
console.log('Content preview:', functionsPage.content.substring(0, 500));
await page.screenshot({ path: '/tmp/functions-page.png' });
await auth.closeBrowser();
console.log('\n=== Test Complete ===');

129
temp/test-classes5.js Normal file
View File

@@ -0,0 +1,129 @@
import auth from '../tools/siemens-auth.js';
console.log('=== Testing NX Open - Accessing Actual Class Pages ===\n');
const browser = await auth.getBrowser();
const page = await browser.newPage();
await page.setViewport({ width: 1400, height: 900 });
await auth.loadCookies(page);
const baseUrl = 'https://docs.sw.siemens.com/documentation/external/PL20200522120320484/en-US/nx_open_python_ref/nx/1980/nx_open_python_ref/en-US/nxopen_python_ref/';
// Navigate to functions.html which we know works
const functionsUrl = baseUrl + 'functions.html';
console.log('Loading:', functionsUrl);
await page.goto(functionsUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
// Handle cookie popup
const cookieBtn = await page.evaluateHandle(() => {
const btns = Array.from(document.querySelectorAll('button'));
return btns.find(b => b.innerText && b.innerText.includes('Accept All Cookies'));
});
if (cookieBtn && cookieBtn.asElement()) {
await cookieBtn.asElement().click();
await new Promise(r => setTimeout(r, 2000));
}
// Find links to actual class pages
const classLinks = await page.evaluate(() => {
const links = Array.from(document.querySelectorAll('a'));
return links
.filter(a => a.href && (a.href.includes('classNXOpen') || a.href.includes('class_n_x_open')))
.map(a => ({ text: a.innerText.trim(), href: a.href }))
.filter(l => l.text.length > 0 && l.text.length < 80)
.slice(0, 30);
});
console.log('Class links found:', classLinks.length);
classLinks.forEach(l => console.log(` - ${l.text}: ${l.href.split('/').pop()}`));
// Find Session class link
const sessionLink = classLinks.find(l =>
l.text.includes('Session') && !l.text.includes('SessionCollection') && !l.text.includes('SessionBuilder')
);
// Or try any class link if Session not found
const targetLink = sessionLink || classLinks[0];
if (targetLink) {
console.log('\n=== Navigating to:', targetLink.text, '===');
console.log('URL:', targetLink.href);
await page.goto(targetLink.href, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
const classPage = await page.evaluate(() => {
return {
title: document.title,
url: window.location.href,
hasError: document.body.innerText.includes('Access Denied') ||
document.body.innerText.includes('<Error>') ||
document.body.innerText.includes('AccessDenied'),
bodyText: document.body.innerText.substring(0, 4000)
};
});
console.log('\nClass page result:');
console.log('Title:', classPage.title);
console.log('URL:', classPage.url);
console.log('Has error:', classPage.hasError);
console.log('\n--- Content ---');
console.log(classPage.bodyText);
await page.screenshot({ path: '/tmp/class-access.png' });
}
// Let's also test the class list functions_s.html to find Session directly
console.log('\n=== Testing functions_s.html (looking for Session) ===');
const functionsSUrl = baseUrl + 'functions_s.html';
await page.goto(functionsSUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
const sessionContent = await page.evaluate(() => {
const text = document.body.innerText;
const sessionLines = text.split('\n').filter(l => l.includes('Session'));
return {
hasError: text.includes('Access Denied'),
sessionLines: sessionLines.slice(0, 20),
sessionLinks: Array.from(document.querySelectorAll('a'))
.filter(a => a.innerText && a.innerText.includes('Session') && a.href)
.map(a => ({ text: a.innerText.trim(), href: a.href }))
.slice(0, 10)
};
});
console.log('Has error:', sessionContent.hasError);
console.log('Session-related lines:');
sessionContent.sessionLines.forEach(l => console.log(` ${l.substring(0, 100)}`));
console.log('\nSession links:');
sessionContent.sessionLinks.forEach(l => console.log(` - ${l.text}: ${l.href.split('/').pop()}`));
// Try to click on a Session link if found
if (sessionContent.sessionLinks.length > 0) {
const sessionClassLink = sessionContent.sessionLinks.find(l =>
l.href.includes('Session') && !l.text.includes('Builder')
) || sessionContent.sessionLinks[0];
console.log('\n=== Clicking on Session link:', sessionClassLink.text, '===');
await page.goto(sessionClassLink.href, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
const sessionPage = await page.evaluate(() => {
return {
title: document.title,
hasError: document.body.innerText.includes('Access Denied'),
content: document.body.innerText.substring(0, 3000)
};
});
console.log('Title:', sessionPage.title);
console.log('Has error:', sessionPage.hasError);
console.log('\n--- Session class content ---');
console.log(sessionPage.content);
await page.screenshot({ path: '/tmp/session-page.png' });
}
await auth.closeBrowser();
console.log('\n=== Test Complete ===');

170
temp/test-find-session.js Normal file
View File

@@ -0,0 +1,170 @@
import auth from '../tools/siemens-auth.js';
console.log('=== Finding NXOpen.Session Class Page ===\n');
const browser = await auth.getBrowser();
const page = await browser.newPage();
await page.setViewport({ width: 1400, height: 900 });
await auth.loadCookies(page);
const baseUrl = 'https://docs.sw.siemens.com/documentation/external/PL20200522120320484/en-US/nx_open_python_ref/nx/1980/nx_open_python_ref/en-US/nxopen_python_ref/';
// Navigate to hierarchy.html and look for Session
console.log('Loading hierarchy.html...');
await page.goto(baseUrl + 'hierarchy.html', { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
// Handle cookie popup
const cookieBtn = await page.evaluateHandle(() => {
const btns = Array.from(document.querySelectorAll('button'));
return btns.find(b => b.innerText && b.innerText.includes('Accept All Cookies'));
});
if (cookieBtn && cookieBtn.asElement()) {
await cookieBtn.asElement().click();
await new Promise(r => setTimeout(r, 2000));
}
// Find Session links in hierarchy
const hierarchyLinks = await page.evaluate(() => {
const links = Array.from(document.querySelectorAll('a'));
return links
.filter(a => a.innerText && a.innerText.trim() === 'Session')
.map(a => ({ text: a.innerText.trim(), href: a.href, file: a.href.split('/').pop() }));
});
console.log('Session links in hierarchy:', hierarchyLinks);
// Try each Session link to find the NXOpen.Session class
for (const link of hierarchyLinks.slice(0, 3)) {
console.log(`\n=== Trying: ${link.file} ===`);
await page.goto(link.href, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
const pageContent = await page.evaluate(() => {
return {
title: document.title,
hasError: document.body.innerText.includes('Access Denied'),
firstLines: document.body.innerText.substring(0, 500)
};
});
console.log('Title:', pageContent.title);
console.log('Has error:', pageContent.hasError);
console.log('Content preview:', pageContent.firstLines);
if (!pageContent.hasError && pageContent.title.includes('Session')) {
// Found a working Session page!
console.log('\n=== FOUND WORKING SESSION PAGE! ===');
// Get full content
const fullContent = await page.evaluate(() => {
return {
title: document.title,
content: document.body.innerText.substring(0, 5000)
};
});
console.log(fullContent.content);
await page.screenshot({ path: '/tmp/nxopen-session.png' });
break;
}
}
// Also try directly searching in class index page for Session (NXOpen)
console.log('\n=== Looking for Session (NXOpen) specifically ===');
await page.goto(baseUrl + 'classes.html', { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
// Get all text and find Session (NXOpen)
const classIndexSearch = await page.evaluate(() => {
const text = document.body.innerText;
// Look for Session followed by (NXOpen) or Session(NXOpen)
const sessionIdx = text.indexOf('Session (NXOpen)');
if (sessionIdx > -1) {
// Get surrounding context
return {
found: true,
context: text.substring(Math.max(0, sessionIdx - 100), sessionIdx + 200)
};
}
return { found: false };
});
console.log('Session (NXOpen) in class index:', classIndexSearch);
// Find the link for Session class under NXOpen namespace
const sessionNXOpenLink = await page.evaluate(() => {
// Get all links
const links = Array.from(document.querySelectorAll('a'));
// Find links that have "Session" text
const sessionLinks = links
.filter(a => a.innerText && a.innerText.trim() === 'Session')
.map(a => {
// Get parent context to identify namespace
let parentText = a.parentElement?.innerText || '';
return {
text: a.innerText.trim(),
href: a.href,
file: a.href.split('/').pop(),
parentContext: parentText.substring(0, 100)
};
});
return sessionLinks;
});
console.log('\nSession links with context:', sessionNXOpenLink);
// Try the NXOpen namespace directly to find Session class
console.log('\n=== Trying NXOpen namespace from annotated.html ===');
await page.goto(baseUrl + 'annotated.html', { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
// Expand NXOpen namespace and look for Session
const annotatedSessionLinks = await page.evaluate(() => {
const links = Array.from(document.querySelectorAll('a.el'));
return links
.filter(a => a.innerText && a.innerText.includes('Session'))
.map(a => ({ text: a.innerText.trim(), href: a.href.split('/').pop() }))
.filter(l => !l.text.includes('.') || l.text.startsWith('NXOpen.Session'))
.slice(0, 20);
});
console.log('Session links from annotated:', annotatedSessionLinks);
// Try the pattern a***.html to find Session directly
// Let's try a55186 (common pattern for main classes)
const testUrls = [
'a55186.html', // Possible Session
'a55188.html',
'a55190.html',
'a55180.html'
];
for (const testUrl of testUrls) {
console.log(`\nTrying ${testUrl}...`);
await page.goto(baseUrl + testUrl, { waitUntil: 'networkidle2', timeout: 30000 });
await new Promise(r => setTimeout(r, 2000));
const testResult = await page.evaluate(() => {
return {
title: document.title,
hasError: document.body.innerText.includes('Access Denied'),
isSession: document.title.includes('Session') && document.title.includes('NXOpen')
};
});
console.log(`${testUrl}: ${testResult.title} (error: ${testResult.hasError})`);
if (!testResult.hasError && testResult.isSession) {
console.log('\n=== FOUND NXOPEN.SESSION! ===');
const content = await page.evaluate(() => document.body.innerText.substring(0, 4000));
console.log(content);
await page.screenshot({ path: '/tmp/nxopen-session-found.png' });
break;
}
}
await auth.closeBrowser();
console.log('\n=== Test Complete ===');

111
temp/test-nxopen.js Normal file
View File

@@ -0,0 +1,111 @@
import auth from './tools/siemens-auth.js';
console.log('=== Testing NX Open Python Reference Access ===\n');
const browser = await auth.getBrowser();
const page = await browser.newPage();
await page.setViewport({ width: 1400, height: 900 });
await auth.loadCookies(page);
const url = 'https://docs.sw.siemens.com/en-US/doc/209349590/PL20200522120320484.nxopen_python_ref?audience=external';
console.log('Loading:', url);
await page.goto(url, { waitUntil: 'networkidle2' });
await new Promise(r => setTimeout(r, 5000));
// Handle cookie popup - click multiple times if needed
for (let i = 0; i < 3; i++) {
const cookieBtn = await page.evaluateHandle(() => {
const btns = Array.from(document.querySelectorAll('button'));
return btns.find(b => b.innerText && b.innerText.includes('Accept All Cookies'));
});
if (cookieBtn && cookieBtn.asElement()) {
console.log('Clicking Accept All Cookies...');
await cookieBtn.asElement().click();
await new Promise(r => setTimeout(r, 1000));
}
}
await new Promise(r => setTimeout(r, 3000));
await page.screenshot({ path: '/tmp/nxopen-1.png' });
// Check for iframes
const frames = page.frames();
console.log('\nFrames found:', frames.length);
frames.forEach((f, i) => console.log(` Frame ${i}: ${f.url().substring(0, 80)}`));
// Look for documentation iframe
let docFrame = null;
for (const frame of frames) {
const frameUrl = frame.url();
if (frameUrl.includes('nxopen') || frameUrl.includes('doxygen') || frameUrl.includes('/doc/')) {
docFrame = frame;
console.log('\nFound doc frame:', frameUrl);
break;
}
}
// If no iframe, check the main page content
console.log('\n=== Main Page Content ===');
const mainContent = await page.evaluate(() => {
// Get all text
const text = document.body.innerText;
// Look for specific elements
const title = document.title;
const h1s = Array.from(document.querySelectorAll('h1')).map(h => h.innerText);
const h2s = Array.from(document.querySelectorAll('h2')).map(h => h.innerText);
return { title, h1s, h2s, text: text.substring(0, 2000) };
});
console.log('Title:', mainContent.title);
console.log('H1s:', mainContent.h1s);
console.log('H2s:', mainContent.h2s);
// Try clicking on "Classes" tab
console.log('\n=== Trying to click Classes ===');
const classesTab = await page.evaluateHandle(() => {
const elements = Array.from(document.querySelectorAll('*'));
return elements.find(e => e.innerText === 'Classes' || e.innerText === 'Classes▼');
});
if (classesTab && classesTab.asElement()) {
console.log('Found Classes element, clicking...');
await classesTab.asElement().click();
await new Promise(r => setTimeout(r, 3000));
await page.screenshot({ path: '/tmp/nxopen-2.png' });
// Get dropdown content
const dropdownContent = await page.evaluate(() => {
const links = Array.from(document.querySelectorAll('a'));
return links
.filter(a => a.innerText && a.href)
.map(a => a.innerText.trim())
.filter(t => t.length > 2 && t.length < 100)
.slice(0, 50);
});
console.log('Dropdown links:', dropdownContent.length);
dropdownContent.slice(0, 30).forEach(l => console.log(' -', l));
}
// Try to find the embedded documentation content
console.log('\n=== Looking for embedded content ===');
const embeddedContent = await page.evaluate(() => {
// Look for common documentation containers
const containers = document.querySelectorAll('iframe, .doc-content, .documentation, #content, main');
const results = [];
containers.forEach(c => {
results.push({
tag: c.tagName,
id: c.id,
className: c.className,
src: c.src || null
});
});
return results;
});
console.log('Found containers:', embeddedContent);
await auth.closeBrowser();
console.log('\nDone!');

View File

@@ -0,0 +1,86 @@
import auth from '../tools/siemens-auth.js';
console.log('=== Accessing NXOpen.Session Class (a03318.html) ===\n');
const browser = await auth.getBrowser();
const page = await browser.newPage();
await page.setViewport({ width: 1400, height: 900 });
await auth.loadCookies(page);
const baseUrl = 'https://docs.sw.siemens.com/documentation/external/PL20200522120320484/en-US/nx_open_python_ref/nx/1980/nx_open_python_ref/en-US/nxopen_python_ref/';
// Navigate to NXOpen.Session class page
const sessionUrl = baseUrl + 'a03318.html';
console.log('Loading:', sessionUrl);
await page.goto(sessionUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
// Handle cookie popup
const cookieBtn = await page.evaluateHandle(() => {
const btns = Array.from(document.querySelectorAll('button'));
return btns.find(b => b.innerText && b.innerText.includes('Accept All Cookies'));
});
if (cookieBtn && cookieBtn.asElement()) {
await cookieBtn.asElement().click();
await new Promise(r => setTimeout(r, 2000));
}
// Get page content
const sessionContent = await page.evaluate(() => {
return {
title: document.title,
url: window.location.href,
hasError: document.body.innerText.includes('Access Denied'),
fullText: document.body.innerText
};
});
console.log('Title:', sessionContent.title);
console.log('URL:', sessionContent.url);
console.log('Has error:', sessionContent.hasError);
if (!sessionContent.hasError) {
console.log('\n=== SUCCESS! NXOpen.Session class documentation ===\n');
console.log(sessionContent.fullText.substring(0, 8000));
await page.screenshot({ path: '/tmp/nxopen-session-success.png' });
// Also test another important class - Part
console.log('\n\n=== Now testing NXOpen.Part class ===');
// First find Part class page ID
await page.goto(baseUrl + 'classes.html', { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 2000));
const partLink = await page.evaluate(() => {
const links = Array.from(document.querySelectorAll('a'));
const partLinks = links
.filter(a => a.innerText && a.innerText.trim() === 'Part')
.map(a => ({ text: a.innerText.trim(), href: a.href, parent: a.parentElement?.innerText?.substring(0, 50) || '' }));
return partLinks.find(l => l.parent.includes('NXOpen')) || partLinks[0];
});
if (partLink) {
console.log('Found Part link:', partLink);
await page.goto(partLink.href, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
const partContent = await page.evaluate(() => {
return {
title: document.title,
hasError: document.body.innerText.includes('Access Denied'),
content: document.body.innerText.substring(0, 3000)
};
});
console.log('Part class title:', partContent.title);
console.log('Has error:', partContent.hasError);
console.log('\nPart class content preview:');
console.log(partContent.content);
}
} else {
console.log('\n=== ERROR: Could not access Session class ===');
console.log(sessionContent.fullText);
}
await auth.closeBrowser();
console.log('\n=== Test Complete ===');

159
temp/test-session.js Normal file
View File

@@ -0,0 +1,159 @@
import auth from '../tools/siemens-auth.js';
console.log('=== Testing NX Open Session Class Access ===\n');
const browser = await auth.getBrowser();
const page = await browser.newPage();
await page.setViewport({ width: 1400, height: 900 });
await auth.loadCookies(page);
const baseUrl = 'https://docs.sw.siemens.com/documentation/external/PL20200522120320484/en-US/nx_open_python_ref/nx/1980/nx_open_python_ref/en-US/nxopen_python_ref/';
// First navigate to the index page to establish session
console.log('Loading index page first...');
await page.goto(baseUrl + 'index.html', { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 2000));
// Handle cookie popup
const cookieBtn = await page.evaluateHandle(() => {
const btns = Array.from(document.querySelectorAll('button'));
return btns.find(b => b.innerText && b.innerText.includes('Accept All Cookies'));
});
if (cookieBtn && cookieBtn.asElement()) {
await cookieBtn.asElement().click();
await new Promise(r => setTimeout(r, 2000));
}
// Try to navigate to Class Index and find Session
console.log('\n=== Looking for NXOpen.Session class ===');
const classIndexUrl = baseUrl + 'classes.html';
await page.goto(classIndexUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
// Get HTML to find the actual Session link
const sessionInfo = await page.evaluate(() => {
const html = document.body.innerHTML;
const text = document.body.innerText;
// Look for Session (NXOpen) in the class index
const sessionMatch = text.match(/Session\s*\(NXOpen\)/);
// Look for all links containing Session
const links = Array.from(document.querySelectorAll('a'));
const sessionLinks = links
.filter(a => a.innerText && a.innerText.includes('Session') && a.href)
.map(a => ({ text: a.innerText.trim(), href: a.href }));
return {
hasSessionInText: sessionMatch ? sessionMatch[0] : null,
sessionLinks: sessionLinks,
// Look for the specific pattern in text
sessionSection: text.split('\n').filter(l => l.includes('Session') && l.includes('NXOpen')).slice(0, 10)
};
});
console.log('Session in text:', sessionInfo.hasSessionInText);
console.log('Session-related lines:', sessionInfo.sessionSection);
console.log('Session links found:', sessionInfo.sessionLinks.length);
sessionInfo.sessionLinks.slice(0, 10).forEach(l => console.log(` - ${l.text}: ${l.href.split('/').pop()}`));
// Navigate to the S section of the class index
console.log('\n=== Checking S section of class index ===');
const sSectionUrl = baseUrl + 'classes.html#letter_s';
await page.goto(sSectionUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 2000));
const sSectionContent = await page.evaluate(() => {
const text = document.body.innerText;
// Find the section starting from S
const sIndex = text.indexOf('\nS\n');
if (sIndex > -1) {
return text.substring(sIndex, sIndex + 3000);
}
// Try to find Session
const sessionIdx = text.indexOf('Session');
if (sessionIdx > -1) {
return text.substring(Math.max(0, sessionIdx - 100), sessionIdx + 500);
}
return text.substring(0, 2000);
});
console.log('S section content:');
console.log(sSectionContent);
// Try to click on Session class from classes page
const sessionClassLinks = await page.evaluate(() => {
const links = Array.from(document.querySelectorAll('a'));
return links
.filter(a => {
const text = a.innerText.trim();
// Look for Session class that's under NXOpen namespace
return text === 'Session' || (text.includes('Session') && !text.includes('Builder') && !text.includes('Collection') && text.length < 30);
})
.map(a => ({ text: a.innerText.trim(), href: a.href, parent: a.parentElement?.innerText?.substring(0, 50) || '' }))
.slice(0, 10);
});
console.log('\nSession class candidates:', sessionClassLinks);
// Try direct access to NXOpen.Session class page using Doxygen naming convention
// Doxygen uses classNXOpen_1_1Session.html format
console.log('\n=== Trying direct Session class URL ===');
const sessionDirectUrl = baseUrl + 'a55186.html'; // This is likely the Session page based on pattern
await page.goto(sessionDirectUrl, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
let sessionPageResult = await page.evaluate(() => {
return {
title: document.title,
url: window.location.href,
hasError: document.body.innerText.includes('Access Denied'),
content: document.body.innerText.substring(0, 3000)
};
});
console.log('Direct URL result:');
console.log('Title:', sessionPageResult.title);
console.log('Has error:', sessionPageResult.hasError);
console.log('Content:', sessionPageResult.content.substring(0, 500));
// If error, try to find Session by navigating from hierarchy
if (sessionPageResult.hasError) {
console.log('\n=== Trying via hierarchy.html ===');
await page.goto(baseUrl + 'hierarchy.html', { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
// Find Session link
const hierarchySession = await page.evaluate(() => {
const links = Array.from(document.querySelectorAll('a'));
const sessionLink = links.find(a => a.innerText.trim() === 'Session');
if (sessionLink) {
return { text: sessionLink.innerText, href: sessionLink.href };
}
return null;
});
if (hierarchySession) {
console.log('Found Session in hierarchy:', hierarchySession);
await page.goto(hierarchySession.href, { waitUntil: 'networkidle2', timeout: 60000 });
await new Promise(r => setTimeout(r, 3000));
sessionPageResult = await page.evaluate(() => {
return {
title: document.title,
url: window.location.href,
hasError: document.body.innerText.includes('Access Denied'),
content: document.body.innerText.substring(0, 3000)
};
});
console.log('\nSession page via hierarchy:');
console.log('Title:', sessionPageResult.title);
console.log('Has error:', sessionPageResult.hasError);
console.log('Content:', sessionPageResult.content);
}
}
await page.screenshot({ path: '/tmp/session-final.png' });
await auth.closeBrowser();
console.log('\n=== Test Complete ===');

25
temp/test-siemens-docs.js Normal file
View File

@@ -0,0 +1,25 @@
import docs from '../tools/siemens-docs.js';
console.log('=== Testing updated siemens-docs.js ===\n');
// Test listAvailableDocs
console.log('1. listAvailableDocs():');
const availableDocs = await docs.listAvailableDocs();
console.log(JSON.stringify(availableDocs, null, 2));
// Test fetchNXOpenClass for Session
console.log('\n2. fetchNXOpenClass("Session"):');
const sessionDocs = await docs.fetchNXOpenClass('Session');
console.log('Title:', sessionDocs.title);
console.log('Has error:', sessionDocs.error ? 'Yes: ' + sessionDocs.error : 'No');
console.log('Content preview:', (sessionDocs.content || '').substring(0, 800));
// Test getNXOpenIndex
console.log('\n3. getNXOpenIndex("functions"):');
const functionsIndex = await docs.getNXOpenIndex('functions');
console.log('Title:', functionsIndex.title);
console.log('Has error:', functionsIndex.error ? 'Yes' : 'No');
console.log('Content preview:', (functionsIndex.content || '').substring(0, 500));
await docs.closeBrowser();
console.log('\n=== Test Complete ===');