testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

Testcafe unable to find install browser

Open shorianita opened this issue 3 years ago • 4 comments

What is your Scenario?

Testcafe unable to find installed browsers. When executing testcafe -b I get this error

ERROR Error: Command failed with exit code 3221226505: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -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 (U:\node_modules\testcafe-browser-tools\node_modules\execa\lib\error.js:56:11) at handlePromise (U:\node_modules\testcafe-browser-tools\node_modules\execa\index.js:114:26) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async searchInRegistry (U:\node_modules\testcafe-browser-tools\lib\api\get-installations.js:64:28) at async findWindowsBrowsers (U:\node_modules\testcafe-browser-tools\lib\api\get-installations.js:80:39) at async findBrowsers (U:\node_modules\testcafe-browser-tools\lib\api\get-installations.js:130:16) at async Object.default_1 [as getInstallations] (U:\node_modules\testcafe-browser-tools\lib\api\get-installations.js:179:30) at async BrowserProviderPluginHost.getBrowserList (U:\node_modules\testcafe\lib\browser\provider\built-in\locally-installed.js:22:31) at async BrowserProvider.getBrowserList (U:\node_modules\testcafe\lib\browser\provider\index.js:208:16) at async listBrowsers (U:\node_modules\testcafe\lib\cli\cli.js:103:30) at async cli (U:\node_modules\testcafe\lib\cli\cli.js:121:13)

What is the Current behavior?

Unable to find installed browser

ERROR Error: Command failed with exit code 3221226505: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -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 (U:\node_modules\testcafe-browser-tools\node_modules\execa\lib\error.js:56:11) at handlePromise (U:\node_modules\testcafe-browser-tools\node_modules\execa\index.js:114:26) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async searchInRegistry (U:\node_modules\testcafe-browser-tools\lib\api\get-installations.js:64:28) at async findWindowsBrowsers (U:\node_modules\testcafe-browser-tools\lib\api\get-installations.js:80:39) at async findBrowsers (U:\node_modules\testcafe-browser-tools\lib\api\get-installations.js:130:16) at async Object.default_1 [as getInstallations] (U:\node_modules\testcafe-browser-tools\lib\api\get-installations.js:179:30) at async BrowserProviderPluginHost.getBrowserList (U:\node_modules\testcafe\lib\browser\provider\built-in\locally-installed.js:22:31) at async BrowserProvider.getBrowserList (U:\node_modules\testcafe\lib\browser\provider\index.js:208:16) at async listBrowsers (U:\node_modules\testcafe\lib\cli\cli.js:103:30) at async cli (U:\node_modules\testcafe\lib\cli\cli.js:121:13)

What is the Expected behavior?

Should display the list of available browser

What is your public website URL? (or attach your complete example)

You can use any since the issue is unable to find the installed browser and it is not working for any code/test.

What is your TestCafe test code?

test('New Test', async t =>{

var email = "abc"+Math.random()+"@gmail.com";

await t .typeText(Selector('#email'),email)

Your complete configuration file

No response

Your complete test report

No response

Screenshots

No response

Steps to Reproduce

  1. execute testcafe -b or execute script testcafe chrome test.js 2. 3.

TestCafe version

1.20.1

Node.js version

v18.14.0

Command-line arguments

testcafe chrome test.js

Browser name(s) and version(s)

No response

Platform(s) and version(s)

Windows

Other

No response

shorianita avatar Mar 16 '23 16:03 shorianita

I assume you have blocked PowerShell or registry access. Without it, you cannot get the list of installed browsers. However, there is a workaround for running tests: specify the path to the browser executable file.

felis2803 avatar Mar 17 '23 06:03 felis2803

@felis2803 Hi the workaround is not working for me, I got the same error testcafe path:"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" .\tests\Transfer\AccountManagement.js ERROR Unable to open the "path:C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" browser due to the following error: Error: Command failed with exit code 3221226505: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -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 (U:\Automation\olb-certification\node_modules\testcafe-browser-tools\node_modules\execa\lib\error.js:56:11)
at handlePromise (U:\Automation\olb-certification\node_modules\testcafe-browser-tools\node_modules\execa\index.js:114:26)
at processTicksAndRejections (node:internal/process/task_queues:95:5) at searchInRegistry (U:\Automation\olb-certification\node_modules\testcafe-browser-tools\src\api\get-installations.js:80:29) at findWindowsBrowsers (U:\Automation\olb-certification\node_modules\testcafe-browser-tools\src\api\get-installations.js:101:39) at findBrowsers (U:\Automation\olb-certification\node_modules\testcafe-browser-tools\src\api\get-installations.js:168:16)
at Object.default_1 [as default] (U:\Automation\olb-certification\node_modules\testcafe-browser-tools\src\api\get-installations.js:223:30) at Object.default_1 (U:\Automation\olb-certification\node_modules\testcafe-browser-tools\src\api\get-browser-info.js:23:27) at BrowserProviderPluginHost._handleString (U:\Automation\olb-certification\node_modules\testcafe\src\browser\provider\built-in\path.js:11:29) at BrowserProviderPluginHost.openBrowser (U:\Automation\olb-certification\node_modules\testcafe\src\browser\provider\built-in\path.js:49:32)

Type "testcafe -h" for help.

shorianita avatar Mar 17 '23 16:03 shorianita

In that case, try Remote Browsers. If this method does not work, then the only thing I can recommend is to check why Power Shell is being blocked - without it, you will not be able to use TestCafe.

felis2803 avatar Mar 21 '23 06:03 felis2803

Hi @shorianita,

The best way to fix the issue is to add the necessary privileges for the user that runs the tests.

miherlosev avatar May 18 '23 04:05 miherlosev