rubycdp / ferrum

Headless Chrome Ruby API
https://ferrum.rubycdp.com
MIT License
1.71k stars 123 forks source link

Questions related to developer tools #282

Closed pccasto closed 2 years ago

pccasto commented 2 years ago

I just discovered the project this afternoon. Thank you - saves me from having to do a bunch of ugly hand crafted calls!

I've got a few interrelated questions - if these should be broken as separate issues, please let me know.

1) I'm trying to launch the developer tools, and other functions without any success. browser.keyboard.type [:ctrl, :shift, 'I'] -- no developer tools browser.keyboard.type [:ctrl, 'u'] -- no source code tab launched

2) When I manually launch the developer tools by interacting with the browser, and then: browser.screenshot path: 'page.png' -- screenshots the base page, but does not include the developer tools sidebar browser.screenshot path: 'page_full.png', full:true -- causes the browser window to paint to the entire screen, but no additional info (titlebar, or developer tools sidebar) [set longer timeout to get results, because of long full page redraw via X]

Some of this could be due to the environment, but before going down the path of moving code around, I wanted to check expectations.

My environment (perhaps a bit more than is relevant, but just in case):

Sure, I could have started with something easier, but what's the fun in that... But it shows why your project is so intriguing!

I did try simplifying by running everything natively on the Mac, but with the same results.

Thanks, and Best Regards, Paul

[ Also - I'm looking through the docs here: https://chromedevtools.github.io/devtools-protocol/ because I realize that some of this functionality is really tied to the core, rather than what you are exposing via the Ruby interface. Just hoping you might have already explored these areas, and have some insights. ]

Nakilon commented 2 years ago

I guess there is no way ferrum can do that. It works within a "html internet browsing window" that is a one component of the browser while devtools are another component. I suppose to automate such things you have to talk to your OS, send the keystrokes on the OS level and screenshot on the OS level. I did that 9 years ago to automate the Yandex Browser testing but it was too long ago so my knowledge on tools is outdated. For Windows it was the "accessibility" layer, for macOS I did that via Applescript. I could definitely answer such question today if pithon wasn't their religion so they got rid of the only rubyist and so unfortunately on later projects I never had to automate on the OS level again.