Comments (4)
@joerg1985, thank you for creating this issue. We will troubleshoot it as soon as we can.
Info for maintainers
Triage this issue by using labels.
If information is missing, add a helpful comment and then I-issue-template
label.
If the issue is a question, add the I-question
label.
If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted
label.
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable G-*
label, and it will provide the correct link and auto-close the
issue.
After troubleshooting the issue, please add the R-awaiting answer
label.
Thank you!
from selenium.
Thank you for raising this. Do you have an example/test that can help reproduce this?
from selenium.
@pujagani i can only provide some code to show this without a browser, see below.
As soon as the delay
between sending network.beforeRequestSent
and network.responseStarted
is high enought everything works as expected. As soon as there are alot of events raised they get out of order, i guess at the point when one thread is not able to consume them sequentially.
I think it should be possible to have this in a real browser as described in the issue.
import java.io.UncheckedIOException;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.bidi.BiDi;
import org.openqa.selenium.bidi.HasBiDi;
import org.openqa.selenium.bidi.module.Network;
import org.openqa.selenium.remote.http.HttpClient;
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.HttpResponse;
import org.openqa.selenium.remote.http.Message;
import org.openqa.selenium.remote.http.TextMessage;
import org.openqa.selenium.remote.http.WebSocket;
public class Connection {
private static WebSocket.Listener LISTENER;
public static void main(String[] args) throws InterruptedException {
int delay = 1; // << increase this to e.g. 40ms to see the code is running fine in case there is a delay between the events
HttpClient client = new HttpClient() {
@Override
public WebSocket openSocket(HttpRequest request, WebSocket.Listener listener) {
LISTENER = listener;
AtomicLong state = new AtomicLong();
return new WebSocket() {
@Override
public WebSocket send(Message message) {
long id = state.incrementAndGet();
if (id < 4) {
// answer the register calls
LISTENER.accept(new TextMessage(
"{\"id\": " + id + ", \"result\": {}, \"type\": \"success\"}"
));
}
return this;
}
@Override
public void close() {
}
};
}
@Override
public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
throw new UnsupportedOperationException("Not supported yet.");
}
};
org.openqa.selenium.bidi.Connection connection = new org.openqa.selenium.bidi.Connection(client, "N/A");
ConcurrentHashMap<String, Boolean> requests = new ConcurrentHashMap<>();
Network network = new Network(new MockDriver(new BiDi(connection)));
network.onBeforeRequestSent((before) -> {
requests.put(before.getRequest().getRequestId(), Boolean.TRUE);
});
network.onResponseStarted((started) -> {
if (requests.putIfAbsent(started.getRequest().getRequestId(), Boolean.FALSE) == null) {
System.err.println(started.getRequest().getRequestId() + " NOT found in map");
System.exit(666);
}
});
// wait to ensure all listeners are in place
Thread.sleep(2000);
for (long i = 4; i < Long.MAX_VALUE; i++) {
if (i % 100 == 0) {
System.out.println("iteration: " + i);
}
LISTENER.accept(new TextMessage("{\"method\": \"network.beforeRequestSent\", \"params\": {"
+ "\"context\": null,"
+ "\"isBlocked\": true,"
+ "\"navigation\": null,"
+ "\"redirectCount\": 0,"
+ "\"request\": {"
+ "\"request\": \"" + i + "\","
+ "\"url\": \"https://url\","
+ "\"method\": \"GET\","
+ "\"headers\": [],"
+ "\"cookies\": [],"
+ "\"headersSize\": 0,"
+ "\"bodySize\": null"
+ "},"
+ "\"timestamp\": " + System.currentTimeMillis()+ ", "
+ "\"initiator\": {\"type\" :\"other\"}"
+ "}}"));
if (delay > 0)
Thread.sleep(delay);
LISTENER.accept(new TextMessage("{\"method\": \"network.responseStarted\", \"params\": {"
+ "\"context\": null,"
+ "\"isBlocked\": true,"
+ "\"navigation\": null,"
+ "\"redirectCount\": 0,"
+ "\"request\": {"
+ "\"request\": \"" + i + "\","
+ "\"url\": \"https://url\","
+ "\"method\": \"GET\","
+ "\"headers\": [],"
+ "\"cookies\": [],"
+ "\"headersSize\": 0,"
+ "\"bodySize\": null"
+ "},"
+ "\"timestamp\": " + System.currentTimeMillis() + ", "
+ "\"response\": {}"
+ "}}"));
}
}
private static class MockDriver implements WebDriver, HasBiDi {
private final BiDi _bidi;
public MockDriver(BiDi bidi) {
_bidi = bidi;
}
@Override
public void get(String url) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getCurrentUrl() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getTitle() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<WebElement> findElements(By by) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public WebElement findElement(By by) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getPageSource() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void close() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void quit() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set<String> getWindowHandles() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getWindowHandle() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public TargetLocator switchTo() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Navigation navigate() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Options manage() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Optional<BiDi> maybeGetBiDi() {
return Optional.of(_bidi);
}
}
}
from selenium.
Thank you so much for sharing this!
from selenium.
Related Issues (20)
- [🐛 Bug]: ExpectedCondition::elementToBeClickable does not consider CSS `pointer-events: none` HOT 12
- [🐛 Bug]: Minitest::UnexpectedError: Selenium::WebDriver::Error::NoSuchWindowError: no such window HOT 9
- [🐛 Bug]: why the docker image selenium/standalone-firefox supports proxy,but chrome doesn't? HOT 1
- [🐛 Bug]: After webdriver.close and quit(), reinstantiating ChromeDriver throws SessionNotCreatedException(JAVA) HOT 2
- [🐛 Bug]: Unable to handle window management popup while opening a new window HOT 1
- [🐛 Bug]: Selenium unable to connect to Chrome 128 when not directly installed HOT 10
- [🐛 Bug]: Selenium BIDI network interception facing an issue with the "network.provideResponse" method HOT 1
- [🚀 Feature]: turn off animation or wait for finish animation HOT 2
- [🐛 Bug]: Timeout set to 16 minutes, but always fails with timeout after 9 minutes HOT 9
- [🐛 Bug]: Cannot connect Nodes to Selenium Hub using Https protocol; HOT 3
- [🐛 Bug]: Testing a chrome problem using chromedriver HOT 2
- [🐛 Bug]: No more UnhandledAlertException with Firefox 129 and problem with BiDi handling of confirmation dialog with Chrome HOT 1
- [🚀 Feature]: Switch to remote driver using an environment variable HOT 5
- [🚀 Feature]: Use self-managed browsers in Docker containers
- [🐛 Bug]: Error after updating to Chrome 128 HOT 7
- [🐛 Bug]: Race condition in ruby library for capybara system tests HOT 3
- [🐛 Bug]: Selenium edge driver cannot go to extension page using codes HOT 2
- [🐛 Bug]: eservice HOT 2
- [🐛 Bug]: "--headlessmode=new" with Chromedriver 128 in container results in SessionNotCreatedException HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from selenium.