Skip to content

Commit fb614e4

Browse files
Merge pull request #36 from AutomateThePlanet/bellatrix-playwright-upgrade
Bellatrix playwright upgrade
2 parents 9a8c167 + 34b02ed commit fb614e4

File tree

285 files changed

+14141
-44
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+14141
-44
lines changed

bellatrix.android/src/main/java/solutions/bellatrix/android/components/AndroidComponent.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import solutions.bellatrix.core.utilities.InstanceFactory;
3838
import solutions.bellatrix.core.utilities.Log;
3939

40+
import java.awt.Dimension;
4041
import java.util.ArrayList;
4142
import java.util.List;
4243
import java.util.Locale;
@@ -102,12 +103,14 @@ public Class<?> getComponentClass() {
102103
return getClass();
103104
}
104105

105-
public Point getLocation() {
106-
return findElement().getLocation();
106+
public java.awt.Point getLocation() {
107+
var location = findElement().getLocation();
108+
return new java.awt.Point(location.getX(), location.getY());
107109
}
108110

109111
public Dimension getSize() {
110-
return findElement().getSize();
112+
var size = findElement().getSize();
113+
return new java.awt.Dimension(size.getWidth(), size.getHeight());
111114
}
112115

113116
public String getAttribute(String name) {

bellatrix.android/src/main/java/solutions/bellatrix/android/services/TouchActionsService.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ public class TouchActionsService extends MobileService {
2929
public <TComponent extends AndroidComponent> TouchActionsService tap(TComponent component, int count) {
3030
TouchAction touchAction = new TouchAction(DriverService.getWrappedAndroidDriver());
3131
touchAction.tap(TapOptions.tapOptions()
32-
.withPosition(PointOption.point(component.getLocation().getX(), component.getLocation().getY())).withTapsCount(count));
32+
.withPosition(PointOption.point((int)component.getLocation().getX(), (int)component.getLocation().getY())).withTapsCount(count));
3333
wrappedMultiAction.add(touchAction);
3434

3535
return this;
3636
}
3737

3838
public <TComponent extends AndroidComponent> TouchActionsService press(TComponent component) {
3939
TouchAction touchAction = new TouchAction(DriverService.getWrappedAndroidDriver());
40-
touchAction.press(PointOption.point(component.getLocation().getX(), component.getLocation().getY()));
40+
touchAction.press(PointOption.point((int)component.getLocation().getX(), (int)component.getLocation().getY()));
4141
wrappedMultiAction.add(touchAction);
4242

4343
return this;
@@ -53,7 +53,7 @@ public TouchActionsService press(Integer x, Integer y) {
5353

5454
public <TComponent extends AndroidComponent> TouchActionsService longPress(TComponent component) {
5555
TouchAction touchAction = new TouchAction(DriverService.getWrappedAndroidDriver());
56-
touchAction.longPress(PointOption.point(component.getLocation().getX(), component.getLocation().getY()));
56+
touchAction.longPress(PointOption.point((int)component.getLocation().getX(), (int)component.getLocation().getY()));
5757
wrappedMultiAction.add(touchAction);
5858

5959
return this;
@@ -78,7 +78,7 @@ public TouchActionsService wait(Long waitTimeMilliseconds) {
7878

7979
public <TComponent extends AndroidComponent> TouchActionsService moveTo(TComponent component) {
8080
TouchAction touchAction = new TouchAction(DriverService.getWrappedAndroidDriver());
81-
touchAction.moveTo(PointOption.point(component.getLocation().getX(), component.getLocation().getY()));
81+
touchAction.moveTo(PointOption.point((int)component.getLocation().getX(), (int)component.getLocation().getY()));
8282
wrappedMultiAction.add(touchAction);
8383

8484
return this;
@@ -103,9 +103,9 @@ public TouchActionsService release() {
103103
public <TComponent extends AndroidComponent> TouchActionsService swipe(TComponent firstComponent, TComponent secondComponent, int duration) {
104104
TouchAction touchAction = new TouchAction(DriverService.getWrappedAndroidDriver());
105105
touchAction
106-
.press(PointOption.point(firstComponent.getLocation().getX(), firstComponent.getLocation().getY()))
106+
.press(PointOption.point((int)firstComponent.getLocation().getX(), (int)firstComponent.getLocation().getY()))
107107
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(duration)))
108-
.moveTo(PointOption.point(secondComponent.getLocation().getX(), secondComponent.getLocation().getY()))
108+
.moveTo(PointOption.point((int)secondComponent.getLocation().getX(), (int)secondComponent.getLocation().getY()))
109109
.release().perform();
110110
wrappedMultiAction.add(touchAction);
111111

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package solutions.bellatrix.core.utilities;
2+
3+
import lombok.SneakyThrows;
4+
5+
public class ConverterService {
6+
public static <SourceT, ResultT> ResultT convert(SourceT source, int index) {
7+
ResultT object = InstanceFactory.createByTypeParameter(source.getClass(), index);
8+
9+
return convert(source, object);
10+
}
11+
12+
public static <SourceT, ResultT> ResultT convert(SourceT source, ResultT result) {
13+
var object = (ResultT) InstanceFactory.create(result.getClass());
14+
15+
var sourceFields = source.getClass().getDeclaredFields();
16+
var objectFields = object.getClass().getDeclaredFields();
17+
18+
for (var sourceField : sourceFields) {
19+
for (var objectField : objectFields) {
20+
if (sourceField.getName().equals(objectField.getName())) {
21+
sourceField.setAccessible(true);
22+
objectField.setAccessible(true);
23+
24+
try {
25+
objectField.set(object, sourceField.get(source));
26+
} catch (IllegalAccessException e) {
27+
throw new RuntimeException(e);
28+
}
29+
break;
30+
}
31+
}
32+
}
33+
34+
return object;
35+
}
36+
37+
@SneakyThrows
38+
public static <SourceT, ResultT> ResultT convertToClass(SourceT source, Class<ResultT> result) {
39+
var object = (ResultT) InstanceFactory.create(result);
40+
41+
var sourceFields = source.getClass().getDeclaredFields();
42+
var objectFields = object.getClass().getDeclaredFields();
43+
44+
for (var sourceField : sourceFields) {
45+
for (var objectField : objectFields) {
46+
if (sourceField.getName().equals(objectField.getName())) {
47+
sourceField.setAccessible(true);
48+
objectField.setAccessible(true);
49+
50+
objectField.set(object, sourceField.get(source));
51+
break;
52+
}
53+
}
54+
}
55+
56+
return object;
57+
}
58+
}

bellatrix.desktop/src/main/java/solutions/bellatrix/desktop/components/DesktopComponent.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import solutions.bellatrix.desktop.services.ComponentWaitService;
3636
import solutions.bellatrix.desktop.waitstrategies.*;
3737

38+
import java.awt.Dimension;
3839
import java.util.ArrayList;
3940
import java.util.List;
4041
import java.util.Locale;
@@ -100,14 +101,15 @@ public Class<?> getComponentClass() {
100101
return getClass();
101102
}
102103

103-
public Point getLocation() {
104-
return findElement().getLocation();
104+
public java.awt.Point getLocation() {
105+
var location = findElement().getLocation();
106+
return new java.awt.Point(location.getX(), location.getY());
105107
}
106108

107109
public Dimension getSize() {
108-
return findElement().getSize();
110+
var size = findElement().getSize();
111+
return new java.awt.Dimension(size.getWidth(), size.getHeight());
109112
}
110-
111113
public String getAttribute(String name) {
112114
return findElement().getAttribute(name);
113115
}

bellatrix.ios/src/main/java/solutions/bellatrix/ios/components/IOSComponent.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import solutions.bellatrix.ios.services.ComponentWaitService;
3535
import solutions.bellatrix.ios.waitstrategies.*;
3636

37+
import java.awt.Dimension;
3738
import java.util.ArrayList;
3839
import java.util.List;
3940
import java.util.Locale;
@@ -99,14 +100,15 @@ public Class<?> getComponentClass() {
99100
return getClass();
100101
}
101102

102-
public Point getLocation() {
103-
return findElement().getLocation();
103+
public java.awt.Point getLocation() {
104+
var location = findElement().getLocation();
105+
return new java.awt.Point(location.getX(), location.getY());
104106
}
105107

106108
public Dimension getSize() {
107-
return findElement().getSize();
109+
var size = findElement().getSize();
110+
return new java.awt.Dimension(size.getWidth(), size.getHeight());
108111
}
109-
110112
public String getAttribute(String name) {
111113
return findElement().getAttribute(name);
112114
}

bellatrix.ios/src/main/java/solutions/bellatrix/ios/services/TouchActionsService.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ public class TouchActionsService extends MobileService {
2828
public <TComponent extends IOSComponent> TouchActionsService tap(TComponent component, int count) {
2929
TouchAction touchAction = new TouchAction(DriverService.getWrappedIOSDriver());
3030
touchAction.tap(TapOptions.tapOptions()
31-
.withPosition(PointOption.point(component.getLocation().getX(), component.getLocation().getY())).withTapsCount(count));
31+
.withPosition(PointOption.point((int)component.getLocation().getX(), (int)component.getLocation().getY())).withTapsCount(count));
3232
wrappedMultiAction.add(touchAction);
3333

3434
return this;
3535
}
3636

3737
public <TComponent extends IOSComponent> TouchActionsService press(TComponent component) {
3838
TouchAction touchAction = new TouchAction(DriverService.getWrappedIOSDriver());
39-
touchAction.press(PointOption.point(component.getLocation().getX(), component.getLocation().getY()));
39+
touchAction.press(PointOption.point((int)component.getLocation().getX(), (int)component.getLocation().getY()));
4040
wrappedMultiAction.add(touchAction);
4141

4242
return this;
@@ -52,7 +52,7 @@ public TouchActionsService press(Integer x, Integer y) {
5252

5353
public <TComponent extends IOSComponent> TouchActionsService longPress(TComponent component) {
5454
TouchAction touchAction = new TouchAction(DriverService.getWrappedIOSDriver());
55-
touchAction.longPress(PointOption.point(component.getLocation().getX(), component.getLocation().getY()));
55+
touchAction.longPress(PointOption.point((int)component.getLocation().getX(), (int)component.getLocation().getY()));
5656
wrappedMultiAction.add(touchAction);
5757

5858
return this;
@@ -77,7 +77,7 @@ public TouchActionsService wait(Long waitTimeMilliseconds) {
7777

7878
public <TComponent extends IOSComponent> TouchActionsService moveTo(TComponent component) {
7979
TouchAction touchAction = new TouchAction(DriverService.getWrappedIOSDriver());
80-
touchAction.moveTo(PointOption.point(component.getLocation().getX(), component.getLocation().getY()));
80+
touchAction.moveTo(PointOption.point((int)component.getLocation().getX(), (int)component.getLocation().getY()));
8181
wrappedMultiAction.add(touchAction);
8282

8383
return this;
@@ -102,9 +102,9 @@ public TouchActionsService release() {
102102
public <TComponent extends IOSComponent> TouchActionsService swipe(TComponent firstComponent, TComponent secondComponent, int duration) {
103103
TouchAction touchAction = new TouchAction(DriverService.getWrappedIOSDriver());
104104
touchAction
105-
.press(PointOption.point(firstComponent.getLocation().getX(), firstComponent.getLocation().getY()))
105+
.press(PointOption.point((int)firstComponent.getLocation().getX(), (int)firstComponent.getLocation().getY()))
106106
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(duration)))
107-
.moveTo(PointOption.point(secondComponent.getLocation().getX(), secondComponent.getLocation().getY()))
107+
.moveTo(PointOption.point((int)secondComponent.getLocation().getX(), (int)secondComponent.getLocation().getY()))
108108
.release().perform();
109109
wrappedMultiAction.add(touchAction);
110110

bellatrix.layout/src/main/java/layout/LayoutComponent.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
package layout;
1515

16-
import org.openqa.selenium.Dimension;
17-
import org.openqa.selenium.Point;
16+
import java.awt.*;
1817

1918
public interface LayoutComponent {
2019
String getComponentName();

bellatrix.layout/src/main/java/layout/LayoutComponentValidationsBuilder.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public LayoutPreciseValidationBuilder rightInside(LayoutComponent secondLayoutCo
8282
}
8383

8484
public FinishValidationBuilder alignedVerticallyAll(LayoutComponent... layoutComponents) {
85-
Integer baseLineRightY = this.getLocation().getX() + this.getSize().getWidth() / 2;
86-
Integer baseLineLeftY = this.getLocation().getX();
85+
Integer baseLineRightY = (int)(this.getLocation().getX() + this.getSize().getWidth() / 2);
86+
Integer baseLineLeftY = (int)this.getLocation().getX();
8787
var comparingComponentsNames = getLayoutComponentsNames(layoutComponents);
8888
Predicate combinedPredicate = (s) -> true;
8989
Arrays.stream(layoutComponents).forEach(c -> {
@@ -100,7 +100,7 @@ public FinishValidationBuilder alignedVerticallyAll(LayoutComponent... layoutCom
100100
}
101101

102102
public FinishValidationBuilder alignedVerticallyCentered(LayoutComponent... layoutComponents) {
103-
Integer baseLineRightY = this.getLocation().getX() + this.getSize().getWidth() / 2;
103+
Integer baseLineRightY = (int)(this.getLocation().getX() + this.getSize().getWidth() / 2);
104104
var comparingComponentsNames = getLayoutComponentsNames(layoutComponents);
105105
Predicate combinedPredicate = (s) -> true;
106106
Arrays.stream(layoutComponents).forEach(c -> {
@@ -114,7 +114,7 @@ public FinishValidationBuilder alignedVerticallyCentered(LayoutComponent... layo
114114
}
115115

116116
public FinishValidationBuilder alignedVerticallyRight(LayoutComponent... layoutComponents) {
117-
Integer baseLineRightY = this.getLocation().getX() + this.getSize().getWidth();
117+
Integer baseLineRightY = (int)(this.getLocation().getX() + this.getSize().getWidth());
118118
var comparingComponentsNames = getLayoutComponentsNames(layoutComponents);
119119
Predicate combinedPredicate = (s) -> true;
120120
Arrays.stream(layoutComponents).forEach(c -> {
@@ -128,7 +128,7 @@ public FinishValidationBuilder alignedVerticallyRight(LayoutComponent... layoutC
128128
}
129129

130130
public FinishValidationBuilder alignedVerticallyLeft(LayoutComponent... layoutComponents) {
131-
Integer baseLineLeftY = this.getLocation().getX();
131+
Integer baseLineLeftY = (int)this.getLocation().getX();
132132
var comparingComponentsNames = getLayoutComponentsNames(layoutComponents);
133133
Predicate combinedPredicate = (s) -> true;
134134
Arrays.stream(layoutComponents).forEach(c -> combinedPredicate.and((r) -> baseLineLeftY.equals(c.getLocation().getX())));
@@ -139,8 +139,8 @@ public FinishValidationBuilder alignedVerticallyLeft(LayoutComponent... layoutCo
139139
}
140140

141141
public FinishValidationBuilder alignedHorizontallyAll(LayoutComponent... layoutComponents) {
142-
Integer baseLineTopY = this.getLocation().getY();
143-
Integer baseLineBottomY = this.getLocation().getY() + this.getSize().getHeight();
142+
Integer baseLineTopY = (int)this.getLocation().getY();
143+
Integer baseLineBottomY = (int)(this.getLocation().getY() + this.getSize().getHeight());
144144
var comparingComponentsNames = getLayoutComponentsNames(layoutComponents);
145145
Predicate combinedPredicate = (s) -> true;
146146
Arrays.stream(layoutComponents).forEach(c -> {
@@ -157,7 +157,7 @@ public FinishValidationBuilder alignedHorizontallyAll(LayoutComponent... layoutC
157157
}
158158

159159
public FinishValidationBuilder alignedHorizontallyCentered(LayoutComponent... layoutComponents) {
160-
Integer baseLineTopY = this.getLocation().getY() + this.getSize().getHeight() / 2;
160+
Integer baseLineTopY = (int)(this.getLocation().getY() + this.getSize().getHeight() / 2);
161161
var comparingComponentsNames = getLayoutComponentsNames(layoutComponents);
162162
Predicate combinedPredicate = (s) -> true;
163163
Arrays.stream(layoutComponents).forEach(c -> {
@@ -171,7 +171,7 @@ public FinishValidationBuilder alignedHorizontallyCentered(LayoutComponent... la
171171
}
172172

173173
public FinishValidationBuilder alignedHorizontallyTop(LayoutComponent... layoutComponents) {
174-
Integer baseLineTopY = this.getLocation().getY();
174+
Integer baseLineTopY = (int)this.getLocation().getY();
175175
var comparingComponentsNames = getLayoutComponentsNames(layoutComponents);
176176
Predicate combinedPredicate = (s) -> true;
177177
Arrays.stream(layoutComponents).forEach(c -> combinedPredicate.and((r) -> baseLineTopY.equals(c.getLocation().getY())));
@@ -182,7 +182,7 @@ public FinishValidationBuilder alignedHorizontallyTop(LayoutComponent... layoutC
182182
}
183183

184184
public FinishValidationBuilder alignedHorizontallyBottom(LayoutComponent... layoutComponents) {
185-
Integer baseLineBottomY = this.getLocation().getY() + this.getSize().getHeight();
185+
Integer baseLineBottomY = (int)(this.getLocation().getY() + this.getSize().getHeight());
186186
var comparingComponentsNames = getLayoutComponentsNames(layoutComponents);
187187
Predicate combinedPredicate = (s) -> true;
188188
Arrays.stream(layoutComponents).forEach(c -> {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>solutions.bellatrix</groupId>
8+
<artifactId>bellatrix</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<groupId>bellatrix</groupId>
13+
<artifactId>bellatrix.playwright.getting.started</artifactId>
14+
15+
<properties>
16+
<maven.compiler.source>19</maven.compiler.source>
17+
<maven.compiler.target>19</maven.compiler.target>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>solutions.bellatrix</groupId>
24+
<artifactId>bellatrix.playwright</artifactId>
25+
<version>1.0-SNAPSHOT</version>
26+
<scope>test</scope>
27+
</dependency>
28+
29+
<dependency>
30+
<groupId>org.hamcrest</groupId>
31+
<artifactId>hamcrest-all</artifactId>
32+
<version>1.3</version>
33+
<scope>test</scope>
34+
</dependency>
35+
36+
<dependency>
37+
<groupId>com.github.javafaker</groupId>
38+
<artifactId>javafaker</artifactId>
39+
<version>1.0.2</version>
40+
</dependency>
41+
42+
<dependency>
43+
<groupId>solutions.bellatrix</groupId>
44+
<artifactId>bellatrix.api</artifactId>
45+
<version>1.0</version>
46+
<scope>compile</scope>
47+
</dependency>
48+
</dependencies>
49+
50+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# Copyright 2022 Automate The Planet Ltd.
3+
# Author: Anton Angelov
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# You may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
#
13+
14+
environment=dev
15+
buildName={randomNumber}

0 commit comments

Comments
 (0)