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

[rb] Adding method to send DevTools commands to Chrome and a helper method to enable downloads on headless Chrome. #5583

Closed

Conversation

pulkitsharma07
Copy link
Contributor

@pulkitsharma07 pulkitsharma07 commented Mar 8, 2018

For: #5159

Files can now be downloaded in headless mode after setting the download directory's path using the #download_path= helper.

Working fine with Chrome 65 (chromedriver 2.36). For earlier versions of Chrome/chromedriver I was facing crashes when downloading files in headless mode.


This change is Reviewable

…ds to Chrome DevTools debugger.

For some reason specs for headless mode are not passing.

Refer:
bayandin/chromedriver@9d18be0
@pulkitsharma07 pulkitsharma07 changed the title [rb] Send DevTools commands to Chrome and helper method for setting the download location. [rb] Adding method to send DevTools commands to Chrome and a helper method to enable downloads on headless Chrome. Mar 8, 2018
driver.find_element(css: 'a').click

# Wait for file to download
5.times do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic can be used using a wait.until command much cleaner, and with more control. If you wait for the temporary file not to be there (It's hard to check but I "think" I may have mentioned this before.

@lmtierney
Copy link
Member

After talking with the chromedriver team, the send_command will be moved to a w3c-compliant protocol extension endpoint (https://w3c.github.io/webdriver/webdriver-spec.html#protocol-extensions). We may want to hold off on this PR until the change.

See the issue raised in the chromium bugtracker: https://bugs.chromium.org/p/chromedriver/issues/detail?id=2307

@lmtierney lmtierney added the C-rb label May 30, 2018
@aasimali
Copy link

@pulkitsharma07

Files can now be downloaded in headless mode after setting the download directory's path using the #download_path= helper.

How Can I do that? Can you please tell me the steps? I use Ubuntu

@p0deje
Copy link
Member

p0deje commented Sep 28, 2018

I don't know how I missed that PR at all 😕 The proposed changes were actually implemented in f77d2f9, so users can use driver.download_path = '/home'.

Sorry if this PR was a waste of your time, I somehow missed it completely. Is there anything else we need to take from here?

@SergeyPirogov
Copy link

Hello, maybe someone know how to send DevTools command?

I am able to use

browser.defineCustomCommand("sendCommand", new CommandInfo("/session/:sessionId/goog/cdp/execute", POST));

Object result = browser.sendCommand("Debugger.enable", new HashMap<>());

but I can not subscribe to event:

Object execute = browser.sendCommand("Debugger.scriptParsed", new HashMap<>());

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

Successfully merging this pull request may close these issues.

7 participants