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

TestCafe on Windows fails with exit code 1 #4665

Closed
Holger2233 opened this issue Jan 20, 2020 · 18 comments · Fixed by DevExpress/testcafe-browser-tools#203
Closed

TestCafe on Windows fails with exit code 1 #4665

Holger2233 opened this issue Jan 20, 2020 · 18 comments · Fixed by DevExpress/testcafe-browser-tools#203
Assignees
Labels
AREA: server FREQUENCY: level 2 STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: browser natives TYPE: bug The described behavior is considered as wrong (bug).
Milestone

Comments

@Holger2233
Copy link

Holger2233 commented Jan 20, 2020

Following up on the previous issue #4646 with TestCafe on Windows, the new TestCafe version 1.8.0. does now fail with a different error:

What is your Test Scenario?

just running testcafe

What is the Current behavior?

testcafe fails with exit code 1 error

What is the Expected behavior?

testcafe runs successfully with any valid test and command options

What is your web application and your TestCafe test code?

n/a

Steps to Reproduce:

Install TestCafe v1.8.0 on Windows as per instructions https://devexpress.github.io/testcafe/documentation/using-testcafe/installing-testcafe.html#local-installation
run testcafe -b command
Result: Running testcafe with any option that involves a browser results in the following error. Only exceptions are testcafe -h and testcafe -v:

ERROR Error: Command failed with exit code 1: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NonInteractive -Command $cp = (C:\WINDOWS\System32\chcp.com | Select-String '\\d+').Matches.Value; Try { C:\WINDOWS\System32\chcp.com 65001; Get-Item 'Registry::HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\*\shell\open\command'|Get-ItemProperty -Name '(default)'|Format-List -Property '(default)','PSPath'|Out-String -Width 2147483647|Write-Host; } Finally { C:\WINDOWS\System32\chcp.com $cp; }
    at makeError (C:\Users\xxx\AppData\Roaming\npm\node_modules\testcafe\node_modules\execa\lib\error.js:56:11)
    at handlePromise (C:\Users\xxx\AppData\Roaming\npm\node_modules\testcafe\node_modules\execa\index.js:114:26)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async searchInRegistry (C:\Users\xxx\AppData\Roaming\npm\node_modules\testcafe\node_modules\testcafe-browser-tools\lib\api\get-installations.js:67:28)
    at async findWindowsBrowsers (C:\Users\xxx\AppData\Roaming\npm\node_modules\testcafe\node_modules\testcafe-browser-tools\lib\api\get-installations.js:83:39)
    at async findBrowsers (C:\Users\xxx\AppData\Roaming\npm\node_modules\testcafe\node_modules\testcafe-browser-tools\lib\api\get-installations.js:133:16)
    at async Object.default_1 [as getInstallations] (C:\Users\xxx\AppData\Roaming\npm\node_modules\testcafe\node_modules\testcafe-browser-tools\lib\api\get-installations.js:181:30)
    at async BrowserProviderPluginHost.getBrowserList (C:\Users\xxx\AppData\Roaming\npm\node_modules\testcafe\lib\browser\provider\built-in\locally-installed.js:22:31)
    at async BrowserProvider.getBrowserList (C:\Users\xxx\AppData\Roaming\npm\node_modules\testcafe\lib\browser\provider\index.js:198:16)
    at async listBrowsers (C:\Users\xxx\AppData\Roaming\npm\node_modules\testcafe\lib\cli\cli.js:103:30)
    at async cli (C:\Users\xxx\AppData\Roaming\npm\node_modules\testcafe\lib\cli\cli.js:121:13)

Your Environment details:

testcafe version: 1.8.0
node.js version: 13.6.0 (64bit)
command-line arguments: e.g. testcafe -b or testcafe chrome ./test.js
platform and version: Windows 10.0.18363
npm version: 6.13.6

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jan 20, 2020
@AndreyBelym
Copy link
Contributor

Thank you for your report. Could you please try to run the following command in your terminal and share results here:

C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NonInteractive -Command $cp = (C:\WINDOWS\System32\chcp.com | Select-String '\\d+').Matches.Value; Try { C:\WINDOWS\System32\chcp.com 65001; Get-Item 'Registry::HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\*\shell\open\command'|Get-ItemProperty -Name '(default)'|Format-List -Property '(default)','PSPath'|Out-String -Width 2147483647|Write-Host; } Finally { C:\WINDOWS\System32\chcp.com $cp; }

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jan 22, 2020
@AndreyBelym AndreyBelym added the STATE: Need clarification An issue lacks information for further research. label Jan 22, 2020
@Holger2233
Copy link
Author

Thanks for your response. Here is the output of the command:

PS>C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NonInteractive -Command $cp = (C:\WINDOWS\System32\chcp.com | Select-String '\\d+').Matches.Value; Try { C:\WINDOWS\System32\chcp.com 65001; Get-Item 'Registry::HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\*\shell\open\command'|Get-ItemProperty -Name '(default)'|Format-List 
-Property '(default)','PSPath'|Out-String -Width 2147483647|Write-Host; } Finally { C:\WINDOWS\System32\chcp.com $cp; }
The variable '$cp' cannot be retrieved because it has not been set.
At line:1 char:92
+ ... hell\v1.0\powershell.exe -NoLogo -NonInteractive -Command $cp = (C:\W ...
+                                                               ~~~
    + CategoryInfo          : InvalidOperation: (cp:String) [], RuntimeException
    + FullyQualifiedErrorId : VariableIsUndefined
 
Active code page: 65001


(default) : "C:\Program Files\Mozilla Firefox\firefox.exe"
PSPath    : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\Firefox-308046B0AF4A39CB\shell\open\command

(default) : "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
PSPath    : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\Google Chrome\shell\open\command

(default) : C:\Program Files\Internet Explorer\iexplore.exe
PSPath    : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\IEXPLORE.EXE\shell\open\command




The variable '$cp' cannot be retrieved because it has not been set.
At line:1 char:465
+ ... 147483647|Write-Host; } Finally { C:\WINDOWS\System32\chcp.com $cp; }
+                                                                    ~~~
    + CategoryInfo          : InvalidOperation: (cp:String) [], RuntimeException
    + FullyQualifiedErrorId : VariableIsUndefined

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jan 22, 2020
@no-response no-response bot removed the STATE: Need clarification An issue lacks information for further research. label Jan 22, 2020
@AndreyBelym
Copy link
Contributor

The output looks pretty normal. I have to prepare a debug build that will display a hidden PowerShell stdout and stderr output. Won't you mind to install it when it is ready?

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jan 23, 2020
@Holger2233
Copy link
Author

Sure, no problem.
In case it helps, a colleague here was able to replicate the original issue reported in #4646, but as he is on leave right now I did not manage to replicate the current behaviour with him, it might be related to the system configuration provided by our internal IT department. Please let me know if you need any more specific information.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jan 23, 2020
@AndreyBelym
Copy link
Contributor

AndreyBelym commented Jan 24, 2020

Thank you for your patience. Please install the debug build by running

npm install https://git.io/JvtxA

or

npm install --global https://git.io/JvtxA

and share the output.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jan 24, 2020
@AndreyBelym AndreyBelym added the STATE: Need clarification An issue lacks information for further research. label Jan 24, 2020
@Holger2233
Copy link
Author

here's the command output:

PS>npm install https://git.io/JvtxA -g
npm ERR! code ENOENT
npm ERR! syscall stat
npm ERR! path C:\Users\holger.hempel\AppData\Roaming\npm\node_modules\testcafe\testcafe-browser-tools.tgz
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, stat 'C:\Users\holger.hempel\AppData\Roaming\npm\node_modules\testcafe\testcafe-browser-tools.tgz'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\holger.hempel\AppData\Roaming\npm-cache\_logs\2020-01-26T21_13_37_657Z-debug.log

2020-01-26T21_13_37_657Z-debug.log

@no-response no-response bot removed the STATE: Need clarification An issue lacks information for further research. label Jan 26, 2020
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jan 26, 2020
@AndreyBelym
Copy link
Contributor

Thank you for the provided output. Unfortunately, this error indicates a problem with the debug build's package. Could you please install the second build by using npm i https://git.io/JvmjR? I've modified the package metadata and now it should be installed correctly.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jan 28, 2020
@Holger2233
Copy link
Author

Ok, done. But it does not look like it generated a logfile this time:

PS>testcafe -b
ERROR NativeBinaryHasFailedError: The C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe process failed with the 1 exit code.
Process output:
Running PowerShell generic profile
Importing AWS modules...
Default AWS region set to 'ap-southeast-2'
Completed PowerShell generic profile
Setting up Prompt
Active code page: 65001


(default) : "C:\Program Files\Mozilla Firefox\firefox.exe"
PSPath    : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\Firefox-308046B0AF4A39CB\shell\open\command

(default) : "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
PSPath    : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\Google Chrome\shell\open\command

(default) : C:\Program Files\Internet Explorer\iexplore.exe
PSPath    : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\IEXPLORE.EXE\shell\open\command




The property 'Matches' cannot be found on this object. Verify that the property exists.
At line:1 char:1
+ $cp = (C:\WINDOWS\System32\chcp.com | Select-String '\\d+').Matches.V ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], PropertyNotFoundException
+ FullyQualifiedErrorId : PropertyNotFoundStrict

The variable '$cp' cannot be retrieved because it has not been set.
At line:1 char:374
+ ... 147483647|Write-Host; } Finally { C:\WINDOWS\System32\chcp.com $cp; }
+                                                                    ~~~
+ CategoryInfo          : InvalidOperation: (cp:String) [], RuntimeException
+ FullyQualifiedErrorId : VariableIsUndefined
    at Object.execPowershell (C:\Users\holger.hempel\AppData\Roaming\npm\node_modules\testcafe\node_modules\testcafe-browser-tools\lib\utils\exec.js:123:15)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)

Type "testcafe -h" for help.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jan 28, 2020
@AndreyBelym AndreyBelym added AREA: server SYSTEM: browser natives TYPE: bug The described behavior is considered as wrong (bug). FREQUENCY: level 2 labels Jan 29, 2020
@AndreyBelym AndreyBelym added this to the Sprint #50 milestone Jan 29, 2020
@AndreyBelym
Copy link
Contributor

AndreyBelym commented Jan 29, 2020

Thank you for your cooperation. I can reproduce the issue now.

It is caused by a combination of enabled PowerShell Strict Mode in your PowerShell profile, this escape sequence in a template string in testcafe-browser-tools and the issue with escape sequences in dedent.

We need to fix the template string and avoid loading user profiles for PowerShell. As a workaround, you can try to locate the Set-StrictMode in your PowerShell profile scripts and remove it.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jan 29, 2020
@Holger2233
Copy link
Author

Hi @AndreyBelym your workaround is doing the trick for now, but do you have any update on this and a potential fix? All I know is that the latest version 1.8.1 that has been released since I raised this issue has not brought any improvements.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Feb 12, 2020
@AndreyBelym
Copy link
Contributor

Unfortunately, we don't have time to fix it and include it into the upcoming release (which is expected to be v1.8.2 and should be released during the next week). But it's very likely that we'll fix it in v.1.8.3 or v1.9.0.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Feb 12, 2020
@AndreyBelym AndreyBelym modified the milestones: Sprint #50, Planned Feb 25, 2020
@Holger2233
Copy link
Author

Hi @AndreyBelym I noticed that v1.8.3 has now been released. I presume the issue has not been addressed, given that it has not been closed?

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Mar 17, 2020
@AlexKamaev
Copy link
Contributor

@Holger2233 yes, we will close the issue once it's fixed.

@Holger2233
Copy link
Author

Hi @AlexKamaev and @AndreyBelym I just installed the latest version 1.8.5 and re-enabled PS strict mode again (which was disabled as temporary workaround), but does not look like the issue is fixed yet. Testcafe still does not run and fails with the error below, while working fine with PS Strict mode disabled.

Tests run in chrome browser
Using locally installed version of TestCafe.
ERROR Error: Command failed with exit code 1: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NonInteractive -Command $cp = (C:\WINDOWS\System32\chcp.com | Select-String '\\d+').Matches.Value; Try { C:\WINDOWS\System32\chcp.com 65001; Get-Item 'Registry::HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\*\shell\open\command'|Get-ItemProperty -Name '(default)'|Format-List -Property '(default)','PSPath'|Out-String -Width 2147483647|Write-Host; } Finally { C:\WINDOWS\System32\chcp.com $cp; }
    at makeError (C:\Dev\integration\test\Integration.Migration.Tests\node_modules\execa\lib\error.js:56:11)
    at handlePromise (C:\Dev\integration\test\Integration.Migration.Tests\node_modules\execa\index.js:114:26)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at searchInRegistry (C:\Dev\integration\test\Integration.Migration.Tests\node_modules\testcafe-browser-tools\src\api\get-installations.js:80:29)
    at findWindowsBrowsers (C:\Dev\integration\test\Integration.Migration.Tests\node_modules\testcafe-browser-tools\src\api\get-installations.js:101:39)
    at findBrowsers (C:\Dev\integration\test\Integration.Migration.Tests\node_modules\testcafe-browser-tools\src\api\get-installations.js:168:16)
    at Object.default_1 [as default] (C:\Dev\integration\test\Integration.Migration.Tests\node_modules\testcafe-browser-tools\src\api\get-installations.js:223:30)
    at Object.default_1 [as getBrowserInfo] (C:\Dev\integration\test\Integration.Migration.Tests\node_modules\testcafe-browser-tools\src\api\get-browser-info.js:23:27)
    at BrowserProviderPluginHost.isValidBrowserName (C:\Dev\integration\test\Integration.Migration.Tests\node_modules\testcafe\src\browser\provider\built-in\dedicated\base.js:35:29)
    at BrowserProvider.isValidBrowserName (C:\Dev\integration\test\Integration.Migration.Tests\node_modules\testcafe\src\browser\provider\index.ts:273:16)
    at Object.getBrowserInfo (C:\Dev\integration\test\Integration.Migration.Tests\node_modules\testcafe\src\browser\provider\pool.js:113:14)
    at async Promise.all (index 0)
    at Bootstrapper._getBrowserInfo (C:\Dev\integration\test\Integration.Migration.Tests\node_modules\testcafe\src\runner\bootstrapper.ts:192:29)
    at Bootstrapper.createRunnableConfiguration (C:\Dev\integration\test\Integration.Migration.Tests\node_modules\testcafe\src\runner\bootstrapper.ts:418:29)

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label May 27, 2020
@AndreyBelym AndreyBelym added the STATE: Awaiting release This issue awaits a release for further actions. label May 28, 2020
@AndreyBelym
Copy link
Contributor

Hi, the fix was merged into our codebase, but we need to publish a new release. The fix will be included in testcafe@1.8.6. I will post a message in this thread when it is available.

@AndreyBelym AndreyBelym removed the STATE: Need response An issue that requires a response or attention from the team. label May 28, 2020
@AndreyBelym
Copy link
Contributor

Thank you for your patience. I want to inform that testcafe@1.8.6 is available. You can install and test it in your environment.

@AndreyBelym AndreyBelym removed the STATE: Awaiting release This issue awaits a release for further actions. label Jun 2, 2020
@lock
Copy link

lock bot commented Jun 24, 2020

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

1 similar comment
@lock
Copy link

lock bot commented Jun 24, 2020

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Jun 24, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AREA: server FREQUENCY: level 2 STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: browser natives TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants