Issue
I want to capture the the requests made by javascript.
I tried with net.lightbody.bmp -> browsermob-core -> 2.1.5
, but after I import this in maven, the chromedriver no longer starts and I get an error.
This is the code which I have:
System.setProperty("webdriver.chrome.driver", "data/chromedriver-91.0.4472.19.exe");
WebDriver driver = new ChromeDriver(); //the error appears here when browsermob is imported
try{
driver.get("https://testpages.herokuapp.com/styled/sync/xhttp-messages.html");
Thread.sleep(5 * 1000);
}catch(Exception e){
e.printStackTrace();
}finally{
driver.quit();
}
Without importing browsermob
, it works.
After import, I have this error:
Exception in thread "main" java.lang.NoSuchMethodError:
com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector;
at org.openqa.selenium.chrome.ChromeOptions.asMap(ChromeOptions.java:292)
at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:94)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:68)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at com.test.core.Test.main(Test.java:27)
How I can fix this error? Or how I can capture the requests made by javascript?
Solution
BrowserMob Proxy uses old version of guava library. It looks like guava defined in browsermob
dependencies are closer to the root in your dependency tree that that is in Selenium dependencies.
To solve that you can add new guava version dependency to your root pom.xml
. The latest one is:
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1.1-jre</version>
</dependency>
Answered By - Alexey R.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.