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

Additional arguments for Сhrome #481

Closed
b2ronn opened this issue Mar 29, 2022 · 10 comments
Closed

Additional arguments for Сhrome #481

b2ronn opened this issue Mar 29, 2022 · 10 comments
Labels
question Further information is requested

Comments

@b2ronn
Copy link

b2ronn commented Mar 29, 2022

is it possible somehow to add extra arguments to launch chrome?

const browser = await chromium.launch({ 
  args : ['--host-resolver-rules="MAP * dev.com"']
});

step("load homepage", async () => {
    await page.goto('https://site.com');
});```
@vigneshshanmugam vigneshshanmugam added the question Further information is requested label Mar 29, 2022
@vigneshshanmugam
Copy link
Member

If the question was to invoke it via Synthetics agent, then yes you could use the CLI --playwright-options or use the synthetics.config.(js|ts) file -

If you are looking for from the Heartbeat side, then we have this issue which would add support for playwright options - elastic/beats#28197

@b2ronn
Copy link
Author

b2ronn commented Mar 29, 2022

if using cli does that mean using something like?
--playwright-options '{launchOptions: {args: [--host-resolver-rules="MAP * www.youtube.com"]}}'

@vigneshshanmugam
Copy link
Member

vigneshshanmugam commented Mar 29, 2022

It would be without the launchOptions key like this --playwright-options '{args: [--host-resolver-rules="MAP * www.youtube.com"]}'

@b2ronn
Copy link
Author

b2ronn commented Mar 29, 2022

when i try to run it through heartbeat through fleet i get an error

{"log.level":"warn","@timestamp":"2022-03-29T21:52:10.911Z","log.origin":{"file.name":"synthexec/synthexec.go","file.line":214},"message":"Error executing command '/usr/share/elastic-agent/.node/node/bin/elastic-synthetics elastic-synthetics --playwright-options '{args: [--host-resolver-rules=\"MAP * www.youtube.com\"]}' --ignore-https-errors --screenshots on --throttling 5d/3u/20l --inline --rich-events' (1): exit status 1","service.name":"heartbeat","ecs.version":"1.6.0"}

@vigneshshanmugam
Copy link
Member

Seems like a JSON parsing issue, Could you try this --playwright-options '{"args":["--host-resolver-rules=\"MAP * www.youtube.com\""]}'

@b2ronn
Copy link
Author

b2ronn commented Mar 29, 2022

if i specify via fleet

--playwright-options '{"args":["--host-resolver-rules=\"MAP * www.youtube.com\""]}'

image
i get an error

{"log.level":"info","@timestamp":"2022-03-29T23:15:28.300Z","log.origin":{"file.name":"synthexec/synthexec.go","file.line":153},"message":"Running command: /usr/share/elastic-agent/.node/node/bin/elastic-synthetics elastic-synthetics --playwright-options '{\"args\":[\"--host-resolver-rules=\\\"MAP * www.youtube.com\\\"\"]}' --ignore-https-errors --screenshots on --throttling 5d/3u/20l --inline --rich-events in directory: ''","service.name":"heartbeat","ecs.version":"1.6.0"}
{"log.level":"info","@timestamp":"2022-03-29T23:15:28.637Z","log.origin":{"file.name":"synthexec/synthexec.go","file.line":255},"message":"stderr: error: unknown option '--playwright-options '{\"args\":[\"--host-resolver-rules=\\\"MAP * www.youtube.com\\\"\"]}''","service.name":"heartbeat","ecs.version":"1.6.0"}
{"log.level":"info","@timestamp":"2022-03-29T23:15:28.641Z","log.origin":{"file.name":"synthexec/synthexec.go","file.line":206},"message":"Command has completed(1): /usr/share/elastic-agent/.node/node/bin/elastic-synthetics elastic-synthetics --playwright-options '{\"args\":[\"--host-resolver-rules=\\\"MAP * www.youtube.com\\\"\"]}' --ignore-https-errors --screenshots on --throttling 5d/3u/20l --inline --rich-events","service.name":"heartbeat","ecs.version":"1.6.0"}
{"log.level":"warn","@timestamp":"2022-03-29T23:15:28.641Z","log.origin":{"file.name":"synthexec/synthexec.go","file.line":214},"message":"Error executing command '/usr/share/elastic-agent/.node/node/bin/elastic-synthetics elastic-synthetics --playwright-options '{\"args\":[\"--host-resolver-rules=\\\"MAP * www.youtube.com\\\"\"]}' --ignore-https-errors --screenshots on --throttling 5d/3u/20l --inline --rich-events' (1): exit status 1","service.name":"heartbeat","ecs.version":"1.6.0"}

You can see the extra escaping of " and /. and then this string is not converted to json.

@vigneshshanmugam
Copy link
Member

Seems like the version of Heartbeat that you are testing on does not the latest synthetics agent which understands that particular configuration. Could you tell me what was the version you are testing on and update HB and try again?

@b2ronn
Copy link
Author

b2ronn commented Mar 30, 2022

updated to latest version

image: 'docker.elastic.co/beats/elastic-agent-complete:8.1.1'
heartbeat--8.1.1[0e2c4c13-1eef-4be6-a180-081a6e094869]
/usr/share/elastic-agent/.node/node/bin/elastic-synthetics -V
1.0.0-beta.22
{"log.level":"info","@timestamp":"2022-03-30T09:04:28.891Z","log.origin":{"file.name":"synthexec/synthexec.go","file.line":153},"message":"Running command: /usr/share/elastic-agent/.node/node/bin/elastic-synthetics elastic-synthetics --playwright-options '{\"args\":[\"--host-resolver-rules=\\\"MAP * www.youtube.com\\\"\"]}' --ignore-https-errors --screenshots on --throttling 5d/3u/20l --inline --rich-events in directory: ''","service.name":"heartbeat","ecs.version":"1.6.0"}
{"log.level":"info","@timestamp":"2022-03-30T09:04:30.801Z","log.origin":{"file.name":"synthexec/synthexec.go","file.line":255},"message":"stderr: error: unknown option '--playwright-options '{\"args\":[\"--host-resolver-rules=\\\"MAP * www.youtube.com\\\"\"]}''","service.name":"heartbeat","ecs.version":"1.6.0"}
{"log.level":"info","@timestamp":"2022-03-30T09:04:30.886Z","log.origin":{"file.name":"synthexec/synthexec.go","file.line":206},"message":"Command has completed(1): /usr/share/elastic-agent/.node/node/bin/elastic-synthetics elastic-synthetics --playwright-options '{\"args\":[\"--host-resolver-rules=\\\"MAP * www.youtube.com\\\"\"]}' --ignore-https-errors --screenshots on --throttling 5d/3u/20l --inline --rich-events","service.name":"heartbeat","ecs.version":"1.6.0"}
{"log.level":"warn","@timestamp":"2022-03-30T09:04:30.886Z","log.origin":{"file.name":"synthexec/synthexec.go","file.line":214},"message":"Error executing command '/usr/share/elastic-agent/.node/node/bin/elastic-synthetics elastic-synthetics --playwright-options '{\"args\":[\"--host-resolver-rules=\\\"MAP * www.youtube.com\\\"\"]}' --ignore-https-errors --screenshots on --throttling 5d/3u/20l --inline --rich-events' (1): exit status 1","service.name":"heartbeat","ecs.version":"1.6.0"}

@vigneshshanmugam
Copy link
Member

@b2ronn Apologies for not catching this upfront, The synthetics_args is not a well documented flag, It takes a array of strings which is why the option you have set is interpreted differently and resulting in unknown option error.

Could you try separating the flag in this way
Screen Shot 2022-03-30 at 9 35 16 AM

In the meanwhile, I will also test it on my side. Thanks.

@vigneshshanmugam
Copy link
Member

Closing as we have a proper way to support this from HB - elastic/beats#31737

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

No branches or pull requests

2 participants