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

Sauce visual clip element #2917

Merged
merged 13 commits into from
Sep 3, 2024
1 change: 1 addition & 0 deletions docs/visual-testing/_partials/_clipping-element.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Alternatively, you can also pass an element directly if you've already queried one from Selenium:
29 changes: 29 additions & 0 deletions docs/visual-testing/integrations/csharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ sidebar_label: C#/.Net

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import ClippingDescription from '../_partials/_clipping-description.md';
import ClippingElement from '../_partials/_clipping-element.md';
import EnvironmentVariables from '../_partials/_environment-variables.md';
import FullPageLimit from '../_partials/_fullpage-limit.md';
import SelectiveDiffing from '../_partials/_selective-diffing.md';
Expand Down Expand Up @@ -441,6 +443,33 @@ await VisualClient.VisualCheck("C# full page config",

<FullPageLimit />

### Clip to an Element

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[sauce.Headings] 'Clip to an Element' should use title case capitalization.


<ClippingDescription />

Example:

```csharp
await VisualClient.VisualCheck("Visible Sale Banner",
new VisualCheckOptions()
{
ClipSelector = ".your-css-selector",
kb-kerem marked this conversation as resolved.
Show resolved Hide resolved
});
```

<ClippingElement />

Example:

```csharp
var element = Driver.FindElementByCssSelector(".your-css-selector");
await VisualClient.VisualCheck("Visible Sale Banner",
new VisualCheckOptions()
{
ClipElement = element,
});
```

## Examples

Two examples are available:
Expand Down
2 changes: 1 addition & 1 deletion docs/visual-testing/integrations/cypress.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ cy.sauceVisualCheck('Inventory Page', {
});
```

### Clip to an element
### Clip to an Element

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[sauce.Headings] 'Clip to an Element' should use title case capitalization.


<ClippingDescription />

Expand Down
22 changes: 21 additions & 1 deletion docs/visual-testing/integrations/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ sidebar_label: Java
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import ClippingDescription from '../_partials/_clipping-description.md';
import ClippingElement from '../_partials/_clipping-element.md';
import FullPageLimit from '../_partials/_fullpage-limit.md';
import EnvironmentVariables from '../_partials/_environment-variables.md';
import SelectiveDiffing from '../_partials/_selective-diffing.md';
Expand Down Expand Up @@ -437,7 +438,7 @@ visual.sauceVisualCheck("Long content page", options);

<FullPageLimit />

### Clip to an element
### Clip to an Element

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[sauce.Headings] 'Clip to an Element' should use title case capitalization.


<ClippingDescription />

Expand All @@ -451,6 +452,25 @@ options.setClipSelector(".your-css-selector");
visual.sauceVisualCheck("Visible Sale Banner", options);
```

<ClippingElement />

Example:

```java
import com.saucelabs.visual.CheckOptions;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;

RemoteWebDriver driver;
...

CheckOptions options = new CheckOptions();
WebElement element = driver.findElement(By.cssSelector(".your-css-selector"));
options.setClipElement(element);
visual.sauceVisualCheck("Visible Sale Banner", options);
```

## Examples

Two examples are available:
Expand Down
14 changes: 13 additions & 1 deletion docs/visual-testing/integrations/nightwatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import FullPageJS from '../_partials/_fullpage-js.md'
import ClippingWDIO from '../_partials/_clipping-webdriver.md';
import ClippingElement from '../_partials/_clipping-element.md';
import EnvironmentVariables from '../_partials/_environment-variables.md';
import SelectiveDiffing from '../_partials/_selective-diffing.md';
import SelectiveDiffingGlobal from '../_partials/_selective-diffing-global.md';
Expand Down Expand Up @@ -358,10 +359,21 @@ browser

<FullPageJS />

### Clip to an element
### Clip to an Element

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[sauce.Headings] 'Clip to an Element' should use title case capitalization.


<ClippingWDIO />

<ClippingElement />

Example:

```ts
await browser.sauceVisualCheck('Visible Sale Banner', {
// An element that we should crop the screenshot to
clipElement: browser.element('.your-css-selector')
})
```

### Fail on failures

By default, Sauce Visual will not fail the test if there are any failures during the comparison process. A failure will be logged in the Sauce Labs Visual dashboard, but the test will continue to run.
Expand Down
14 changes: 13 additions & 1 deletion docs/visual-testing/integrations/webdriverio.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sidebar_label: WebdriverIO

import FullPageJS from '../_partials/_fullpage-js.md';
import ClippingWDIO from '../_partials/_clipping-webdriver.md';
import ClippingElement from '../_partials/_clipping-element.md';
import EnvironmentVariables from '../_partials/_environment-variables.md';
import SelectiveDiffing from '../_partials/_selective-diffing.md';
import SelectiveDiffingGlobal from '../_partials/_selective-diffing-global.md';
Expand Down Expand Up @@ -268,10 +269,21 @@ browser.sauceVisualCheck('Before Login', {

<FullPageJS />

### Clip to an element
### Clip to an Element

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[sauce.Headings] 'Clip to an Element' should use title case capitalization.


<ClippingWDIO />

<ClippingElement />

Example:

```ts
await browser.sauceVisualCheck('Visible Sale Banner', {
// An element that we should crop the screenshot to
clipElement: await $('.your-css-selector')
})
```

## Example

An example project is available [here](https://github.com/saucelabs/visual-examples/tree/main/wdio).