Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public <T> T getAttribute(Element element, String attributeName, Class<T> clazz)
}
}

@Deprecated
public static String convertAbsoluteXpathToCss(String xpath) {
String cssSelector = xpath.replace(NODE, CHILD_COMBINATOR);

Expand All @@ -115,6 +116,7 @@ public static String convertAbsoluteXpathToCss(String xpath) {
return semiFinalLocator;
}

@Deprecated
public static String removeDanglingChildCombinatorsFromCss(String css) {
// convert to array by splitting the css by the child combinator
// and remove from that array empty steps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import solutions.bellatrix.playwright.components.options.actions.HoverOptions;
import solutions.bellatrix.playwright.components.options.actions.UncheckOptions;
import solutions.bellatrix.playwright.components.options.states.BoundingBoxOptions;
import solutions.bellatrix.playwright.components.shadowdom.ShadowDomService;
import solutions.bellatrix.playwright.components.shadowdom.ShadowRoot;
import solutions.bellatrix.playwright.configuration.WebSettings;
import solutions.bellatrix.playwright.findstrategies.*;
Expand Down Expand Up @@ -325,7 +326,16 @@ protected String defaultGetWidthAttribute() {
}

protected String defaultGetInnerHtmlAttribute() {
return Optional.ofNullable(findLocator().innerHTML()).orElse("");
if (!(this.inShadowContext())) {
return Optional.ofNullable(findLocator().innerHTML()).orElse("");
} else {
if (this instanceof ShadowRoot) {
return ShadowDomService.getShadowHtml(this, true);
} else {
return ShadowDomService.getShadowHtml(this, false);
}
}

}

protected String defaultGetForAttribute() {
Expand Down Expand Up @@ -1388,4 +1398,15 @@ public <TComponent extends WebComponent> List<TComponent> shadowRootCreateAllByI
public <TComponent extends WebComponent> List<TComponent> shadowRootCreateAllByInnerTextContaining(Class<TComponent> componentClass, String innerText) {
return create().allBy(componentClass, new InnerTextContainingFindStrategy(innerText));
}

private boolean inShadowContext() {
var component = this;

while (component != null) {
if (component instanceof ShadowRoot) return true;
component = component.getParentComponent();
}

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import solutions.bellatrix.playwright.findstrategies.XpathFindStrategy;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -137,12 +138,8 @@ public void forEachRow(Consumer<GridRow> action) {

public GridCell getCell(int row, int column) {
String xpath = HtmlService.getAbsoluteXpath(getTableService().getCell(row, column));
// if (innerXpath.startsWith(".")) innerXpath = innerXpath.substring(1);
// String outerXpath = getCurrentElementXPath();
//
// String fullXpath = Objects.requireNonNullElse(outerXpath, ".") + innerXpath;

GridCell cell = this.create().byXpath(GridCell.class, xpath);
GridCell cell = this.create().byXpath(GridCell.class, "." + xpath);
setCellMetaData(cell, row, column);

return cell;
Expand Down Expand Up @@ -310,8 +307,13 @@ public <TRowObject> void assertTable(Class<TRowObject> clazz, List<TRowObject> e
if (!clazz.equals(Object.class)) {
entity = castRow(clazz, i, propsNotToCompare);
} else {
Method method = this.getClass().getMethod("castRow", int.class, List.class);
entity = (TRowObject)method.invoke(this, i, Arrays.stream(propsNotToCompare).toList());
Method method = null;
try {
method = this.getClass().getMethod("castRow", int.class, List.class);
entity = (TRowObject)method.invoke(this, i, Arrays.stream(propsNotToCompare).toList());
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
EntitiesAsserter.areEqual(expectedEntities.get(i), entity, propsNotToCompare);
}
Expand Down Expand Up @@ -355,9 +357,10 @@ public <TRowObject> TRowObject castRow(Class<TRowObject> clazz, int rowIndex, St
}

var dto = InstanceFactory.create(clazz);
var fields = clazz.getFields();
var fields = clazz.getDeclaredFields();
for (var field : fields) {
var fieldType = field.getType();
field.setAccessible(true);

var headerInfo = getHeaderNamesService().getHeaderInfoByField(field);

Expand Down Expand Up @@ -492,7 +495,9 @@ public <TComponent extends WebComponent, TFindStrategy extends FindStrategy> Gri

public <TGridModel> Grid setModelColumns(Class<TGridModel> clazz) {
controlColumnDataCollection = new ArrayList<>();
for (var field : clazz.getFields()) {
List<Field> declaredFields = List.of(clazz.getDeclaredFields());
for (var field : declaredFields) {
field.setAccessible(true);
var headerName = field.isAnnotationPresent(TableHeader.class) ? field.getAnnotation(TableHeader.class).name() : field.getName();
controlColumnDataCollection.add(new ControlColumnData(headerName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public <TComponent extends WebComponent, TFindStrategy extends FindStrategy> TCo
TComponent newComponent;

if (inShadowContext()) {
newComponent = ShadowDomService.createInShadowContext((WebComponent)baseComponent, componentClass, findStrategy);
newComponent = ShadowDomService.createInShadowContext(componentClass, (WebComponent)baseComponent, findStrategy);
} else {
newComponent = createFromParentComponent(componentClass, findStrategy);
}
Expand All @@ -69,7 +69,7 @@ public <TComponent extends WebComponent, TFindStrategy extends FindStrategy> Lis
List<TComponent> componentList = new ArrayList<>();

if (inShadowContext()) {
componentList = ShadowDomService.createAllInShadowContext((WebComponent)baseComponent, componentClass, findStrategy);
componentList = ShadowDomService.createAllInShadowContext(componentClass, (WebComponent)baseComponent, findStrategy);
} else {
var elements = findStrategy.convert(baseComponent.getWrappedElement()).all();

Expand Down
Loading
Loading