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

appArgs inside Configuration file doesn't allow whitespaces ( ) or quotation marks (") #111

Open
carvedcow opened this issue Feb 13, 2024 · 9 comments

Comments

@carvedcow
Copy link

Hi, I'm trying to use app arguments for my executable electron application but I'm having 2 issues.

  1. If an argument contains a white space, it would automatically add quotation marks around the argument:
{
    "mainWindowUrl": "./index.html",
    "appArgs": ["--test:1"]
}
vs
{
    "mainWindowUrl": "./index.html",
    "appArgs": ["--test: 1"]
}

Here is the app's arguments in Task Manager:
image
vs
image

  1. Quotation marks aren't escaped properly and breaks escape characters:
{
    "mainWindowUrl": "./index.html",
    "appArgs": ["--location=C:\\"]
}
vs
{
    "mainWindowUrl": "./index.html",
    "appArgs": ["--location=\"C:\\\""]
}

image
vs
image

Thank you very much for your time.

@PavelMor25
Copy link
Contributor

Hello @carvedcow,

It's expected that an argument containing a space is wrapped in quotes because this allows you to pass a single argument as a string.
If you need to obtain a string like --test: 1, split your argument into two and write it in appArgs: "appArgs": ["--test:", "1"].

In the second case, try enclosing your path in single quotes: "appArgs": ["--location='C:'"].

Please let us know your results.

@carvedcow
Copy link
Author

Hi @PavelMor25,

Thank you very much for your reply.

The multiple arguments trick worked for white spaces.

For the quotation marks however, the electron application requires double quotation marks. I've tried ' and ` and both wouldn't work.

Is there no way to have quotation marks (") inside an app argument?

Best regards,

@PavelMor25
Copy link
Contributor

You can try using a JavaScript configuration file instead of JSON:

module.exports = {
    mainWindowUrl: './index.html',
    appArgs: ['--test:', '1', '--location="C://"'],
}

@carvedcow
Copy link
Author

After using:

module.exports = {
    mainWindowUrl: './index.html',
    appArgs: ['--test:', '1', '--location="C://"'],
}

The backslash and quotation marks would show up:
image

@PavelMor25
Copy link
Contributor

Can you share a minimal working example? I will try find a solution for your usage scenario. Currently, I can't determinate where the issue occurs.

@carvedcow
Copy link
Author

Apologies for the late response, here is a minimal working example:
https://github.com/carvedcow/test_hello_world

The goal is to be able to run the testScript.js script on the test.exe electron application with the app arguments provided in .testcafe-electron-rc.js.

When I launch the test, the argument I want testcafe to use for the app is:
test.exe --test=".\test folder\test.html"
but I can't get the proper formatting.

Thank you

@PavelMor25
Copy link
Contributor

Hello @carvedcow,

Thank you for sharing the code.

Could you modify the example so that we can reproduce your scenario or that it shows exactly which arguments are passed into the application? Currently, when running testScript.js, the test passes, and we can't determine the issue.

@carvedcow
Copy link
Author

Hi @PavelMor25,

I've updated the code to display the argument being passed from .testcafe-electron-rc.js to testScript.js but the actual argument being used by test.exe is displayed under the Details tab in the Task Manager during test.exe's runtime.

Thank you.

Copy link

We appreciate you taking the time to share information about this issue. We reproduced the bug and added this ticket to our internal task queue. We'll update this thread once we have news.

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

No branches or pull requests

2 participants