Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug message Could not get window title is printed to console when using getActiveWindow #614

Closed
2 of 3 tasks
jweingarten-rv opened this issue Apr 2, 2025 · 8 comments
Closed
2 of 3 tasks

Comments

@jweingarten-rv
Copy link

jweingarten-rv commented Apr 2, 2025

Version

"@nut-tree/nl-matcher": "^3.1.0",
    "@nut-tree/nut-js": "^4.5.1",
    "@nut-tree/plugin-azure": "^2.1.1",

Short overview
When using await nut.getActiveWindow() we see debug messages on the console with text Could not get window title.

Issue occurs on

  • Virtual machine
  • Docker container
  • Dev/Host system

node version:

  • v20.11.0
  • v22.11.0

OS type and version:
Mac only, not windows.

Detailed error description
When using await nut.getActiveWindow() we see debug messages on the console with text Could not get window title.
A grep through my node_modules folder shows these matches only, so I am thinking its something that comes from the NutJS libs:

grep -r -i "Could not get window title" *
Binary file @nut-tree/libnut-darwin/build/Release/libnut.node matches
Binary file @nut-tree/libnut-darwin-legacy-screencapture/build/Release/libnut.node matches

Full code sample to reproduce
Don't have one right now. I am hoping that you actually find the string in your code base and can let me know how I can avoid the message showing up. My users, who write automated tests, just see this message and its concerning them, because they think its the reason for a test failure, but obviously it isn't. It seems like its just a debug message.

@s1hofmann
Copy link
Member

Hi @jweingarten-rv 👋

I can confirm this issue, will be adressed!

Best regards

Simon

@s1hofmann
Copy link
Member

@jweingarten-rv Could you give @nut-tree/nut-js@next a try?

@jweingarten-rv
Copy link
Author

Sorry, but I still see them. Here is I think whats happening for me in most cases.

  • From our product we do something like Drag&Drop items from a Mac Finder window into our Product.
  • So we start the product under test
  • Open a finder window using open -a Finder in a shell script
  • Go to a folder and look for the file we want to start to drag&drop
  • Let's say the test fails to find that file, the typical flow then is to fail the test case, shut down/close our product
  • For us every test case starts the product and closes it.
  • During shut down/closing of our product we try to close any potential popup / window that was opened by our tests.
  • The code for that looks something like this
                        let maxPopupCounter = 3;
                        while (maxPopupCounter >= 0) {
                            const activeWindow = await nut.getActiveWindow();
                            const activeWindowTitle = await activeWindow.getTitle();
                            if (activeWindowTitle.indexOf('Product_Title') < 0) {
                                await actionUtils.pressKeyboardShortcut(
                                    {shortcutName: platformUtils.isWindows() ? 'close_window' : 'escape'},);
                            } else {
                                break;
                            }
                            maxPopupCounter = maxPopupCounter - 1;
                        }

The goal of this loop is to close any potential product popup by pressing escape.

Now if that code is executed, while a Finder window is open, we see the Could not get window title message on the console.

Hope this helps.

@s1hofmann
Copy link
Member

Hi @jweingarten-rv 👋

The snapshot release pipeline needed a change, could you try again with a clean cache?

Regarding your snippet, did you give the findAll mechanism a try?

@jweingarten-rv
Copy link
Author

Sorry, but I must be doing something wrong. Here is what I did

  • npm cache clean --force
  • rm -rf node_modules
  • rm package-lock.json
  • Update package.json to
     "@nut-tree/nl-matcher": "^3.1.0",
    "@nut-tree/nut-js": "next",
    "@nut-tree/plugin-azure": "^2.1.1",
  • npm install
  • run test
    And I still see the log message. I guess I am not sure how exactly I point to next.

findAll not sure how this is going to help me. A test can end in leaving a product modal dialog open, leave a context menu open, or leave an external window like the finder window on top. While it may be possible to find my product window based on title, it doesn't mean I can focus it. Some of the dialogs, from within the test, that can be shown, are modal. I played with it before, but hadn't yet figure out how to make that work. Basically I want to focus the application process, close any modal dialog, close any non-modal dialog, and then quit the app.

@s1hofmann
Copy link
Member

Sorry, but I must be doing something wrong. Here is what I did

You can install the latest snapshot by running npm i @nut-tree/nut-js@next

@jweingarten-rv
Copy link
Author

Well, I did try that, but because of the warnings I wasn't sure if I should use this.

npm i @nut-tree/nut-js@next
npm warn ERESOLVE overriding peer dependency
npm warn While resolving: [email protected]
npm warn Found: @nut-tree/[email protected]
npm warn node_modules/@nut-tree/nut-js
npm warn   peer @nut-tree/nut-js@"^4.0.0" from @nut-tree/[email protected]
npm warn   node_modules/@nut-tree/nl-matcher
npm warn     @nut-tree/nl-matcher@"^3.1.0" from the root project
npm warn   2 more (@nut-tree/plugin-azure, the root project)
npm warn
npm warn Could not resolve dependency:
npm warn peer @nut-tree/nut-js@"^4.0.0" from @nut-tree/[email protected]
npm warn node_modules/@nut-tree/nl-matcher
npm warn   @nut-tree/nl-matcher@"^3.1.0" from the root project
npm warn ERESOLVE overriding peer dependency
npm warn While resolving: [email protected]
npm warn Found: @nut-tree/[email protected]
npm warn node_modules/@nut-tree/nut-js
npm warn   peer @nut-tree/nut-js@"^4.0.0" from @nut-tree/[email protected]
npm warn   node_modules/@nut-tree/nl-matcher
npm warn     @nut-tree/nl-matcher@"^3.1.0" from the root project
npm warn   2 more (@nut-tree/plugin-azure, the root project)
npm warn
npm warn Could not resolve dependency:
npm warn peer @nut-tree/nut-js@"^4.3.0" from @nut-tree/[email protected]
npm warn node_modules/@nut-tree/plugin-azure
npm warn   @nut-tree/plugin-azure@"^2.1.1" from the root project

Anyway. Yes I can confirm that its fixed with version @nut-tree/nut-js": "^4.6.1-next.20250407160755

Thank you very much!

@s1hofmann
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants