com.applitools.eyes.playwright.universal.mapper.TRegionMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eyes-playwright-java5 Show documentation
Show all versions of eyes-playwright-java5 Show documentation
Applitools Eyes SDK for Playwright Java
package com.applitools.eyes.playwright.universal.mapper;
import com.applitools.ICheckSettings;
import com.applitools.eyes.Region;
import com.applitools.eyes.playwright.fluent.PlaywrightCheckSettings;
import com.applitools.eyes.playwright.universal.Refer;
import com.applitools.eyes.playwright.universal.dto.Element;
import com.applitools.eyes.playwright.universal.dto.Selector;
import com.applitools.eyes.universal.Reference;
import com.applitools.eyes.universal.dto.TRegion;
import com.applitools.eyes.universal.mapper.RectangleRegionMapper;
import com.microsoft.playwright.ElementHandle;
import com.microsoft.playwright.Locator;
public class TRegionMapper {
public static TRegion toTRegionFromCheckSettings(ICheckSettings checkSettings, Refer refer, Reference root) {
if (!(checkSettings instanceof PlaywrightCheckSettings)) {
return null;
}
PlaywrightCheckSettings playwrightCheckSettings = (PlaywrightCheckSettings) checkSettings;
Reference element = playwrightCheckSettings.getTargetElement();
if (element != null) {
if (element instanceof Element) {
ElementHandle elementHandle = ((Element) element).getElementHandle();
element.setApplitoolsRefId(refer.ref(elementHandle, root));
} else if (element instanceof Selector){
Selector selector = (Selector) element;
if (selector.getLocator() != null) {
Locator locator = selector.getLocator();
element.setApplitoolsRefId(refer.ref(locator, root));
}
}
return element;
}
Region region = playwrightCheckSettings.getTargetRegion();
if (region != null) {
return RectangleRegionMapper.toRectangleRegionDto(region);
}
return null;
}
public static TRegion toTRegionDtoFromSRE(Reference scrollRootElement, Refer refer, Reference root) {
if (scrollRootElement == null) {
return null;
}
if (scrollRootElement instanceof Element) {
ElementHandle elementHandle = ((Element) scrollRootElement).getElementHandle();
scrollRootElement.setApplitoolsRefId(refer.ref(elementHandle, root));
} else if (scrollRootElement instanceof Selector) {
Selector selector = (Selector) scrollRootElement;
if (selector.getLocator() != null) {
Locator locator = selector.getLocator();
scrollRootElement.setApplitoolsRefId(refer.ref(locator, root));
}
}
return scrollRootElement;
}
}