Vrtgs / thirtyfour

Selenium WebDriver client for Rust, for automated testing of websites
Other
1.06k stars 77 forks source link

Capture console.log? #87

Open tbmreza opened 2 years ago

tbmreza commented 2 years ago

I found a similar question on stack overflow, using Java client.

LogEntries logs = driver.manage().logs().get(LogType.BROWSER);

https://stackoverflow.com/a/26488661

Maybe a new method that behaves like page_source()? Is this currently possible?

stevepryde commented 2 years ago

Ah, yes I forgot about that one. Looks like that is implemented via a non-W3C command called getLog (url is /session/$sessionId/se/log or /session/$sessionId/se/log/types).

Unfortunately this isn't currently possible in thirtyfour but it could be added.

It could be implemented by adding the command under the Command enum and wiring it up to the SessionHandle struct. I'm not sure what data/format it wants as input/output. You could probably use trial and error and inspect the data or otherwise read through the Java/python selenium code to find out.

tbmreza commented 2 years ago

Thanks, that's more than enough pointer for me to start exploring! ^^

(To any contributors who come across this issue: I love you so much if you're about to submit a pull request implementing this.)

AustinHellerRepo commented 1 year ago

Has there been any progress on this front? I'm about to dig into this issue and would like to know if anyone has any feedback/trial-and-error experience.

tbmreza commented 1 year ago

I think I gave up early back then. I can only offer you this link from my bookmarks https://github.com/mozilla/geckodriver/issues/284#issuecomment-477677764 @AustinHellerRepo

tgrushka commented 5 months ago

Hi @stevepryde , I am brand new to Rust and trying to port all of my NodeJS playwright tests to be run by Rust instead, hopefully with thirtyfour (also looking at chromiumoxide). Is there any way you could give us an example of how to grab the console logs? It seems many of the NodeJS webdriver libraries provide these callbacks, but sadly none of those in Rust seem to have it yet. I really don't know enough about CDP (or Rust for that matter) to help implement, sorry. There must be a CDP command to send and a way to get streaming data, or at minimum, grab a snapshot of the logs/console errors at the end of a test run. Is there any way to use thirtyfour as-is to request the logs, even if the ChromeCommands enum doesn't have it, and get the returned data? Please give us something, as the above link did not help as this Rust crate is very different than the NodeJS examples. I don't care about Firefox, if it doesn't have that ability. Thanks.