Skip to content

Commit 449e0ff

Browse files
committed
Adding support for full-page screenshot command to .NET Firefox driver
1 parent 2a47bee commit 449e0ff

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

dotnet/src/webdriver/Firefox/FirefoxDriver.cs

+13
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public class FirefoxDriver : RemoteWebDriver
7070
private const string SetContextCommand = "setContext";
7171
private const string InstallAddOnCommand = "installAddOn";
7272
private const string UninstallAddOnCommand = "uninstallAddOn";
73+
private const string GetFullPageScreenshotCommand = "fullPageScreenshot";
7374

7475
/// <summary>
7576
/// Initializes a new instance of the <see cref="FirefoxDriver"/> class.
@@ -153,6 +154,7 @@ public FirefoxDriver(FirefoxDriverService service, FirefoxOptions options, TimeS
153154
this.AddCustomFirefoxCommand(SetContextCommand, CommandInfo.PostCommand, "/session/{sessionId}/moz/context");
154155
this.AddCustomFirefoxCommand(InstallAddOnCommand, CommandInfo.PostCommand, "/session/{sessionId}/moz/addon/install");
155156
this.AddCustomFirefoxCommand(UninstallAddOnCommand, CommandInfo.PostCommand, "/session/{sessionId}/moz/addon/uninstall");
157+
this.AddCustomFirefoxCommand(GetFullPageScreenshotCommand, CommandInfo.GetCommand, "/session/{sessionId}/moz/screenshot/full");
156158
}
157159

158160
/// <summary>
@@ -242,6 +244,17 @@ public void UninstallAddOn(string addOnId)
242244
this.Execute(UninstallAddOnCommand, parameters);
243245
}
244246

247+
/// <summary>
248+
/// Gets a <see cref="Screenshot"/> object representing the image of the full page on the screen.
249+
/// </summary>
250+
/// <returns>A <see cref="Screenshot"/> object containing the image.</returns>
251+
public Screenshot GetFullPageScreenshot()
252+
{
253+
Response screenshotResponse = this.Execute(GetFullPageScreenshotCommand, null);
254+
string base64 = screenshotResponse.Value.ToString();
255+
return new Screenshot(base64);
256+
}
257+
245258
/// <summary>
246259
/// In derived classes, the <see cref="PrepareEnvironment"/> method prepares the environment for test execution.
247260
/// </summary>

0 commit comments

Comments
 (0)