Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f04443e

Browse files
Update to Selenium 4.33.0 +semver:feature (#150)
* Update to Selenium 4.33.0 +semver:feature * devtools v85-> v137, hotfix of compatibility issues * handle cookies for manytools * Rework relative locator tests, stabilize testByImageLocator * stabilize testByImageLocator * Fix review issues
1 parent b55fc89 commit f04443e

File tree

11 files changed

+172
-217
lines changed

11 files changed

+172
-217
lines changed

‎pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<dependency>
8383
<groupId>com.github.aquality-automation</groupId>
8484
<artifactId>aquality-selenium-core</artifactId>
85-
<version>4.5.0</version>
85+
<version>4.6.0</version>
8686
</dependency>
8787
<dependency>
8888
<groupId>org.apache.commons</groupId>

‎src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.openqa.selenium.devtools.DevTools;
1010
import org.openqa.selenium.devtools.Event;
1111
import org.openqa.selenium.devtools.HasDevTools;
12-
import org.openqa.selenium.devtools.v85.performance.Performance;
13-
import org.openqa.selenium.devtools.v85.performance.model.Metric;
12+
import org.openqa.selenium.devtools.v137.performance.Performance;
13+
import org.openqa.selenium.devtools.v137.performance.model.Metric;
1414

1515
import java.util.List;
1616
import java.util.Map;

‎src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import org.apache.commons.lang3.StringUtils;
44
import org.openqa.selenium.devtools.Command;
5-
import org.openqa.selenium.devtools.v85.dom.model.RGBA;
6-
import org.openqa.selenium.devtools.v85.emulation.Emulation;
7-
import org.openqa.selenium.devtools.v85.emulation.model.MediaFeature;
8-
import org.openqa.selenium.devtools.v85.emulation.model.ScreenOrientation;
5+
import org.openqa.selenium.devtools.v137.dom.model.RGBA;
6+
import org.openqa.selenium.devtools.v137.emulation.Emulation;
7+
import org.openqa.selenium.devtools.v137.emulation.model.MediaFeature;
8+
import org.openqa.selenium.devtools.v137.emulation.model.ScreenOrientation;
99

1010
import java.util.Collections;
1111
import java.util.List;
@@ -45,7 +45,8 @@ public boolean canEmulate() {
4545
* @param accuracy Accuracy of the location
4646
*/
4747
public void setGeolocationOverride(double latitude, double longitude, double accuracy) {
48-
setGeolocationOverride(Optional.of(latitude), Optional.of(longitude), Optional.of(accuracy));
48+
setGeolocationOverride(Optional.of(latitude), Optional.of(longitude), Optional.of(accuracy), Optional.empty(),
49+
Optional.empty(), Optional.empty(), Optional.empty());
4950
}
5051

5152
/**
@@ -64,8 +65,10 @@ public void setGeolocationOverride(double latitude, double longitude) {
6465
* @param longitude Longitude of location
6566
* @param accuracy Accuracy of the location
6667
*/
67-
public void setGeolocationOverride(Optional<Number> latitude, Optional<Number> longitude, Optional<Number> accuracy) {
68-
tools.sendCommand(Emulation.setGeolocationOverride(latitude, longitude, accuracy));
68+
public void setGeolocationOverride(Optional<Number> latitude, Optional<Number> longitude, Optional<Number> accuracy,
69+
Optional<Number> altitude, Optional<Number> altitudeAccuracy, Optional<Number> heading,
70+
Optional<Number> speed) {
71+
tools.sendCommand(Emulation.setGeolocationOverride(latitude, longitude, accuracy, altitude, altitudeAccuracy, heading, speed));
6972
}
7073

7174
/**
@@ -115,7 +118,7 @@ public void setDeviceMetricsOverride(Integer width, Integer height, Number devic
115118
screenOrientation = Optional.of(new ScreenOrientation(ScreenOrientation.Type.fromString(screenOrientationType.get()), angle));
116119
}
117120
tools.sendCommand(Emulation.setDeviceMetricsOverride(width, height, deviceScaleFactor, mobile, Optional.empty(), Optional.empty(), Optional.empty(),
118-
Optional.empty(), Optional.empty(), Optional.empty(), screenOrientation, Optional.empty()));
121+
Optional.empty(), Optional.empty(), Optional.empty(), screenOrientation, Optional.empty(), Optional.empty(), Optional.empty()));
119122
}
120123

121124
/**

‎src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
import org.openqa.selenium.devtools.idealized.Javascript;
1313
import org.openqa.selenium.devtools.idealized.ScriptId;
1414
import org.openqa.selenium.devtools.idealized.target.model.SessionID;
15-
import org.openqa.selenium.devtools.v85.page.Page;
16-
import org.openqa.selenium.devtools.v85.page.model.ScriptIdentifier;
17-
import org.openqa.selenium.devtools.v85.runtime.Runtime;
15+
import org.openqa.selenium.devtools.v137.page.Page;
16+
import org.openqa.selenium.devtools.v137.page.model.ScriptIdentifier;
17+
import org.openqa.selenium.devtools.v137.runtime.Runtime;
1818
import org.openqa.selenium.logging.EventType;
1919
import org.openqa.selenium.logging.HasLogEvents;
2020
import org.openqa.selenium.remote.Augmenter;
@@ -55,7 +55,7 @@ public JavaScriptHandling(DevToolsHandling tools) {
5555
public void addScriptCallbackBinding(String scriptName) {
5656
logger.info("loc.browser.javascript.scriptcallbackbinding.add", scriptName);
5757
bindings.add(scriptName);
58-
tools.sendCommand(Runtime.addBinding(scriptName, Optional.empty()));
58+
tools.sendCommand(Runtime.addBinding(scriptName, Optional.empty(), Optional.empty()));
5959
}
6060

6161
/**

‎src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.openqa.selenium.UsernameAndPassword;
99
import org.openqa.selenium.devtools.NetworkInterceptor;
1010
import org.openqa.selenium.devtools.idealized.Network;
11-
import org.openqa.selenium.devtools.v85.network.model.*;
11+
import org.openqa.selenium.devtools.v137.network.model.*;
1212
import org.openqa.selenium.remote.http.*;
1313

1414
import java.net.URI;
@@ -22,11 +22,11 @@
2222

2323
import static aquality.selenium.browser.AqualityServices.getBrowser;
2424
import static aquality.selenium.logging.LocalizedLoggerUtility.logByLevel;
25-
import static org.openqa.selenium.devtools.v85.network.Network.*;
25+
import static org.openqa.selenium.devtools.v137.network.Network.*;
2626

2727
/**
2828
* DevTools commands for version-independent network interception.
29-
* For more information, see {@link org.openqa.selenium.devtools.v85.network.Network} and {@link Network}.
29+
* For more information, see {@link org.openqa.selenium.devtools.v137.network.Network} and {@link Network}.
3030
*/
3131
public class NetworkHandling {
3232
public static final String LOC_NETWORK_INTERCEPTOR_START = "loc.browser.network.interceptor.start";
@@ -199,7 +199,7 @@ private Consumer<ResponseReceived> getResponseLogger(HttpExchangeLoggingOptions
199199
formatHeaders(response.getHeaders()));
200200
}
201201
if (loggingOptions.getResponseBody().isEnabled()) {
202-
String responseBody = tools.sendCommand(org.openqa.selenium.devtools.v85.network.Network.getResponseBody(requestId)).getBody();
202+
String responseBody = tools.sendCommand(org.openqa.selenium.devtools.v137.network.Network.getResponseBody(requestId)).getBody();
203203
if (StringUtils.isNotEmpty(responseBody)) {
204204
logByLevel(loggingOptions.getResponseBody().getLogLevel(),
205205
"loc.browser.network.event.responsereceived.log.body",
@@ -323,7 +323,8 @@ public void clearNetworkInterceptor() {
323323
*/
324324
public void emulateConditions(Boolean offline, Number latency, Number downloadThroughput, Number uploadThroughput) {
325325
tools.sendCommand(enable(Optional.empty(), Optional.empty(), Optional.empty()));
326-
tools.sendCommand(emulateNetworkConditions(offline, latency, downloadThroughput, uploadThroughput, Optional.empty()));
326+
tools.sendCommand(emulateNetworkConditions(offline, latency, downloadThroughput, uploadThroughput, Optional.empty(),
327+
Optional.empty(), Optional.empty(), Optional.empty()));
327328
}
328329

329330
/**
@@ -339,6 +340,6 @@ public void emulateConditions(Boolean offline, Number latency, Number downloadTh
339340
public void emulateConditions(Boolean offline, Number latency, Number downloadThroughput, Number uploadThroughput, String connectionType) {
340341
tools.sendCommand(enable(Optional.empty(), Optional.empty(), Optional.empty()));
341342
tools.sendCommand(emulateNetworkConditions(offline, latency, downloadThroughput, uploadThroughput,
342-
Optional.of(ConnectionType.fromString(connectionType))));
343+
Optional.of(ConnectionType.fromString(connectionType)), Optional.empty(), Optional.empty(), Optional.empty()));
343344
}
344345
}

‎src/test/java/automationpractice/forms/ChallengingDomForm.java

Lines changed: 5 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -7,89 +7,17 @@
77
public class ChallengingDomForm extends Form {
88

99
public static final String LOCATOR_CHALLENGING_DOM_FORM = "//h3[contains(text(),'Challenging DOM')]";
10-
public static final String ELEMENT_NAME_ROW3_COLUMN5 = "Cell in row 3 column 5";
11-
public static final String ELEMENT_NAME_ROW5_COLUMN5 = "Cell in row 5 column 5";
12-
public static final String ELEMENT_NAME_ROW7_COLUMN5 = "Cell in row 7 column 5";
13-
public static final String ELEMENT_NAME_ROW5_COLUMN7 = "Cell in row 5 column 7";
14-
public static final String ELEMENT_NAME_ROW5_COLUMN3 = "Cell in row 5 column 3";
15-
public static final String ELEMENT_NAME_ROW1_COLUMN1 = "Cell in row 1 column 1";
16-
public static final String ELEMENT_NAME_ROW2_COLUMN1 = "Cell in row 2 column 1";
17-
public static final String ELEMENT_NAME_HEADER_CHALLENGING_DOM = "Header of Challenging Dom";
18-
19-
private final String locatorCellRow5Column5 = "//tr[5]/td[5]";
20-
private final String locatorCellRow3Column5 = "//tr[3]/td[5]";
21-
private final String locatorCellRow7Column5 = "//tr[7]/td[5]";
22-
private final String locatorCellRow5Column3 = "//tr[5]/td[3]";
23-
private final String locatorCellRow5Column7 = "//tr[5]/td[7]";
24-
private final String locatorCellRow1Column1 = "//tr[1]/td[1]";
25-
private final String locatorCellRow2Column1 = "//tr[2]/td[1]";
26-
27-
private ILabel headerName = getElementFactory().getLabel(By.xpath(LOCATOR_CHALLENGING_DOM_FORM), ELEMENT_NAME_HEADER_CHALLENGING_DOM);
28-
private ILabel cellInRow3Column5 = getElementFactory().getLabel(By.xpath(locatorCellRow3Column5), ELEMENT_NAME_ROW3_COLUMN5);
29-
private ILabel cellInRow5Column5 = getElementFactory().getLabel(By.xpath(locatorCellRow5Column5), ELEMENT_NAME_ROW5_COLUMN5);
30-
private ILabel cellInRow7Column5 = getElementFactory().getLabel(By.xpath(locatorCellRow7Column5), ELEMENT_NAME_ROW7_COLUMN5);
31-
private ILabel cellInRow5Column7 = getElementFactory().getLabel(By.xpath(locatorCellRow5Column7), ELEMENT_NAME_ROW5_COLUMN7);
32-
private ILabel cellInRow5Column3 = getElementFactory().getLabel(By.xpath(locatorCellRow5Column3), ELEMENT_NAME_ROW5_COLUMN3);
33-
private ILabel cellInRow1Column1 = getElementFactory().getLabel(By.xpath(locatorCellRow1Column1), ELEMENT_NAME_ROW1_COLUMN1);
34-
private ILabel cellInRow2Column1 = getElementFactory().getLabel(By.xpath(locatorCellRow2Column1), ELEMENT_NAME_ROW2_COLUMN1);
3510

3611
public ChallengingDomForm() {
37-
super(By.xpath(LOCATOR_CHALLENGING_DOM_FORM), "Challenging DOM");
38-
}
39-
40-
public ILabel getCellInRow3Column5() {
41-
return cellInRow3Column5;
12+
super(By.xpath(LOCATOR_CHALLENGING_DOM_FORM), "Challenging Dom");
4213
}
4314

44-
public ILabelgetCellInRow5Column5() {
45-
return cellInRow5Column5;
15+
public StringgetHeaderText() {
16+
return getFormLabel().getText();
4617
}
4718

48-
public ILabel getCellInRow7Column5() {
49-
return cellInRow7Column5;
19+
public ILabel getCell(introw, intcolumn) {
20+
return getElementFactory().getLabel(By.xpath(String.format("//tr[%d]/td[%d]", row, column)), String.format("Cell at row %d and column %d", row, column));
5021
}
5122

52-
public ILabel getCellInRow5Column7() {
53-
return cellInRow5Column7;
54-
}
55-
56-
public ILabel getCellInRow5Column3() {
57-
return cellInRow5Column3;
58-
}
59-
60-
public ILabel getCellInRow1Column1() {
61-
return cellInRow1Column1;
62-
}
63-
64-
public ILabel getCellInRow2Column1() {
65-
return cellInRow2Column1;
66-
}
67-
68-
public ILabel getHeaderName() {
69-
return headerName;
70-
}
71-
72-
public String getLocatorCellRow1Column1() {
73-
return locatorCellRow1Column1;
74-
}
75-
76-
public String getLocatorCellRow5Column5() {
77-
return locatorCellRow5Column5;
78-
}
79-
80-
public String getLocatorCellRow3Column5() {
81-
return locatorCellRow3Column5;
82-
}
83-
84-
public String getLocatorCellRow7Column5() {
85-
return locatorCellRow7Column5;
86-
}
87-
88-
public String getLocatorCellRow5Column3() {
89-
return locatorCellRow5Column3;
90-
}
91-
92-
public String getLocatorCellRow5Column7() {
93-
return locatorCellRow5Column7;
94-
}
9523
}

‎src/test/java/manytools/ManyToolsForm.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import aquality.selenium.browser.AqualityServices;
44
import aquality.selenium.core.utilities.IActionRetrier;
5+
import aquality.selenium.elements.interfaces.IButton;
56
import aquality.selenium.elements.interfaces.ILabel;
67
import aquality.selenium.forms.Form;
78
import org.openqa.selenium.By;
@@ -12,6 +13,7 @@
1213
public abstract class ManyToolsForm<T extends ManyToolsForm<T>> extends Form {
1314
private static final String BASE_URL = "https://manytools.org/";
1415
private final ILabel lblValue = getFormLabel().findChildElement(By.xpath(".//code"), getName(), ILabel.class);
16+
private final IButton btnAgree = getElementFactory().getButton(By.xpath("//button[@mode='primary']"), "Agree");
1517

1618
protected ManyToolsForm(String name) {
1719
super(By.id("maincontent"), name);
@@ -24,6 +26,11 @@ public T open() {
2426
AqualityServices.get(IActionRetrier.class).doWithRetry(() -> {
2527
AqualityServices.getBrowser().goTo(BASE_URL + getUrlPart());
2628
AqualityServices.getBrowser().waitForPageToLoad();
29+
if (btnAgree.state().isDisplayed())
30+
{
31+
btnAgree.click();
32+
btnAgree.state().waitForNotDisplayed();
33+
}
2734
}, Collections.singletonList(TimeoutException.class));
2835
return (T) this;
2936
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /