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

Support lighthouse reports #310

Merged
merged 19 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions config/neodymium.properties
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,45 @@ neodymium.workInProgress = false
# If false: the test data json of the corresponding test does not get attached to the allure report
neodymium.report.enableTestDataInReport = true

#############################
#
# Lighthouse
#
#############################

# Specifies the path to the Lighthouse executable
# If Lighthouse is globally installed and available in PATH, use only the name of the Lighthouse binary
# If Lighthouse is not globally installed and available in PATH, use the absolute/relative path to the Lighthouse binary
neodymium.lighthouse.binaryPath = lighthouse
wurzelkuchen marked this conversation as resolved.
Show resolved Hide resolved

# Specifies the minimum acceptable score for the performance category in Lighthouse reports
# If the Lighthouse performance score falls below this threshold, the test will fail
# Range: 0.0 - 1.0 (representing 0% to 100%)
# The actual value for the performance score varies alot, so consider using a lower threshold to avoid a lot of false alerts
neodymium.lighthouse.assert.thresholdScore.performance = 0.5
wurzelkuchen marked this conversation as resolved.
Show resolved Hide resolved

# Specifies the minimum acceptable score for the accessibility category in Lighthouse reports
# If the Lighthouse accessibility score falls below this threshold, the test will fail
# Range: 0.0 - 1.0 (representing 0% to 100%)
# The actual value for the accessibility score varies alot, so consider using a lower threshold to avoid a lot of false alerts
neodymium.lighthouse.assert.thresholdScore.accessibility = 0.5

# Specifies the minimum acceptable score for the best practices category in Lighthouse reports
# If the Lighthouse best practices score falls below this threshold, the test will fail
# Range: 0.0 - 1.0 (representing 0% to 100%)
# The actual value for the best practices score varies alot, so consider using a lower threshold to avoid a lot of false alerts
neodymium.lighthouse.assert.thresholdScore.bestPractices = 0.5

# Specifies the minimum acceptable score for the seo category in Lighthouse reports
# If the Lighthouse seo score falls below this threshold, the test will fail
# Range: 0.0 - 1.0 (representing 0% to 100%)
# The actual value for the seo score varies alot, so consider using a lower threshold to avoid a lot of false alerts
neodymium.lighthouse.assert.thresholdScore.seo = 0.5

# To be able to validate Lighthouse report audits, we use internal json id's from the report itself
# A full list of all audit id's and their corresponding titles can be found here: https://github.com/Xceptance/neodymium/wiki/Reports#lighthouse-audit-validation
#neodymium.lighthouse.assert.audits =
wurzelkuchen marked this conversation as resolved.
Show resolved Hide resolved

#############################
#
# Proxy configuration properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.openqa.selenium.firefox.GeckoDriverService.Builder;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerOptions;
import org.openqa.selenium.net.PortProber;
import org.openqa.selenium.os.ExecutableFinder;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.HttpCommandExecutor;
Expand Down Expand Up @@ -235,6 +236,12 @@ else if (Neodymium.configuration().useProxy())
{
options.addArguments("--headless");
}

// find a free port for each chrome session (important for lighthouse)
var remoteDebuggingPort = PortProber.findFreePort();
Neodymium.setRemoteDebuggingPort(remoteDebuggingPort);
options.addArguments("--remote-debugging-port=" + remoteDebuggingPort);

if (config.getArguments() != null && config.getArguments().size() > 0)
{
options.addArguments(config.getArguments());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.lang.reflect.InvocationTargetException;
import java.util.Date;

import org.openqa.selenium.NoSuchWindowException;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
Expand Down Expand Up @@ -84,10 +85,18 @@ public synchronized void run()
{
long start = new Date().getTime();

File file = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
writer.compressImageIfNeeded(file, recordingConfigurations.imageScaleFactor(), recordingConfigurations.imageQuality());
writer.write(file);

try
{
File file = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);

writer.compressImageIfNeeded(file, recordingConfigurations.imageScaleFactor(), recordingConfigurations.imageQuality());
writer.write(file);
}
catch (NoSuchWindowException e)
{
// catching the exception prevents the video from failing
}

long duration = new Date().getTime() - start;
millis += duration;
turns++;
Expand Down
Loading