-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
initial commit - integrate lighthouse #1350
Conversation
@ptrthomas - this is draft work - something on the lines of progress so far - Summary -
This is just a sample - wanted to pick your brain before going too further with this. Please let me know, Thank you for the opportunity. |
@@ -138,4 +139,6 @@ | |||
|
|||
void robot(String expression); | |||
|
|||
void lightHouseWrapper(String URL, List<String> options) throws IOException, InterruptedException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrapper around node installed lighthouse module. This takes the URL to analyze and is configurable [ options ].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for all driver stuff I prefer this as a driver.lighthouse()
API
I know, it is a shift from how karate started, but something I think about. some thoughts here: #398
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ptrthomas - actually, this capability isn't linked to driver, hence I didn't placed it there. Lighthouse is cli based, and creates its own cdp session.
@@ -222,4 +226,24 @@ public static String fixJavaScriptFunction(String text) { | |||
} | |||
} | |||
|
|||
public static class KStreamGobbler implements Runnable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utility method to invoke lighthouse on underlying OS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I understand. is this a CLI ? do be aware of the utilities that already exist: https://stackoverflow.com/a/62911366/143475
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah - its pretty much same thing as Karate CLI support -
@@ -1149,4 +1151,28 @@ public void stop(StepResult lastStepResult) { | |||
} | |||
} | |||
|
|||
public void lightHouseWrapperAction(String URL, List<String> options) throws IOException, InterruptedException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actual lighthouse wrapper implementation - this can be configured further for many different options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it IS a CLI - ! see my comment above. I think you should first get that working as a custom feature and experiment - that may be a good enough first version / experiment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah! actually, in that case we might not need any of this at all - since Karate CLI support is good enough to run this all -
* def proc = karate.fork('lighthouse https://github.com/login --only-categories=accessibility,performance -- output=json --emulated-form-factor=none --throttling-method=provided')
* proc.waitSync()
* match proc.exitCode == 0
and I hope there is support to parse the response from command to fetch scores / details for categories like accessibility / performance etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, so let us start with this simple approach then. this is a good starting point to invite more contributions - at least it helps others including me to get up and running with axe / lighthouse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, so anything further needed for this work? since its all pre-existing with CLI support...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I think for now this PR can be parked. instead I think if you create a Git example project maybe with a Docker script included that shows how you can call axe / lighthouse and integrate into a karate test via CLI - that would be a great reference that we can build on. does that make sense ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah sure, will do. Thank you.
* print LHR.categories.accessibility.score | ||
* print LHR.categories.performance.score | ||
#* match LHR.categories.accessibility.score == 0.96 | ||
#* match LHR.categories.performance.score == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possible further work to check for > , < threshold values on accessibility / performance etc scores. Additionally, we can generate complete report.
@@ -968,4 +969,29 @@ public void inputFile(String locator, String... relativePaths) { | |||
method("DOM.setFileInputFiles").param("files", files).param("nodeId", nodeId).send(); | |||
} | |||
|
|||
public void enableAccessibility() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attempted devtools protocols around -
-
enable accessibility -> getFullAXTree ( this tree by itself isnt useful). Need some standard implementations to parse it.
-
enable audits -> this generates events around issues primarily CORS / mixed content type issues.
-
enable performance -> getMetrics gives current page load metrics.
All above not much useful ( except performance, which is already provided by lighthouse ).
Just wanted to demonstrate the attempt :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm can you point to a sample of getFullAXTree
result if really needed, we can write a custom parser. I'm confident of doing these things if it is JSON. the new rewrite
code can even handle scraping HTML BTW
@@ -138,4 +139,6 @@ | |||
|
|||
void robot(String expression); | |||
|
|||
void lightHouseWrapper(String URL, List<String> options) throws IOException, InterruptedException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for all driver stuff I prefer this as a driver.lighthouse()
API
I know, it is a shift from how karate started, but something I think about. some thoughts here: #398
@@ -222,4 +226,24 @@ public static String fixJavaScriptFunction(String text) { | |||
} | |||
} | |||
|
|||
public static class KStreamGobbler implements Runnable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I understand. is this a CLI ? do be aware of the utilities that already exist: https://stackoverflow.com/a/62911366/143475
@@ -1149,4 +1151,28 @@ public void stop(StepResult lastStepResult) { | |||
} | |||
} | |||
|
|||
public void lightHouseWrapperAction(String URL, List<String> options) throws IOException, InterruptedException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it IS a CLI - ! see my comment above. I think you should first get that working as a custom feature and experiment - that may be a good enough first version / experiment
@@ -968,4 +969,29 @@ public void inputFile(String locator, String... relativePaths) { | |||
method("DOM.setFileInputFiles").param("files", files).param("nodeId", nodeId).send(); | |||
} | |||
|
|||
public void enableAccessibility() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm can you point to a sample of getFullAXTree
result if really needed, we can write a custom parser. I'm confident of doing these things if it is JSON. the new rewrite
code can even handle scraping HTML BTW
Draft PR for lighthouse integration