Skip to content

get Har Log as java object from selenium #9

Description

@joshhe

Hi,

I am wondering if there is way to get the har log as a string or object using selenium in java? Currently I would have to read from the saved har file and read that in as a string. I know we can trigger the har export through java script, but I don't know how to get it in the java code...

Something like this?
driver.get("https://google.com");
if(driver instanceof JavascriptExecutor) {
((JavascriptExecutor) driver).executeScript(
" var options = { token: "mySpecialValue", getData: true, title: "Title for the HAR log", jsonp: false,};" +
"HAR.triggerExport(options).then(result => { var har = JSON.parse(result.data); console.log("HAR log: ", har.log);}, err => { console.error(err);});");
}

then, how do I get it in java code...
Thanks!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions