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

Question: Change User Agent during Runtime / execute command #36

Open
pboese opened this issue Mar 12, 2024 · 1 comment
Open

Question: Change User Agent during Runtime / execute command #36

pboese opened this issue Mar 12, 2024 · 1 comment

Comments

@pboese
Copy link

pboese commented Mar 12, 2024

Heya,

first I wanted to thank you for this awesome package, it really helps a lot!

For a very specific use case I need to change the user agent of the local chrome browser during runtime. I found https://stackoverflow.com/questions/67077671/how-to-change-at-runtime-the-user-agent-of-a-remote-selenium-driver but I have no clue how to run execute (execute_cdp_command) in Laravel. Is there a way to achieve this?

Thanks a lot for any help,

Pelle

@pboese
Copy link
Author

pboese commented Mar 12, 2024

Update: There is a way in theory, e.g.

$browser->browser->driver->executeCustomCommand(
    '/session/:sessionId/goog/cdp/execute',
    'POST',
    ['cmd' => 'Network.setUserAgentOverride', 'params' => ['userAgent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36']],
);

In reality it does not work because $browser is protected in NunoMaduro\LaravelConsoleDusk\ConsoleBrowser :-(

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

1 participant