An incident of TooLongFrameException occurs while utilizing Selenium in conjunction with BrowserMob

When utilizing Selenium with BrowserMob for testing purposes, I implement requestfilter and responsefilter to adjust the request header and response contents as follows:

public void proxySettings(){

    proxy.addResponseFilter((response, contents, messageInfo) -> {
        if((messageInfo.getOriginalRequest().toString().contains("/draft/footer"))&&(response.getStatus().code()==200)){
            contents.setTextContents(FileUtil.read("JsonPool//draft_footer.json"));
        }
    });
    proxy.addRequestFilter(new RequestFilter() {
        @Override
        public io.netty.handler.codec.http.HttpResponse filterRequest(io.netty.handler.codec.http.HttpRequest request,HttpMessageContents contents, HttpMessageInfo messageInfo) {
            if(messageInfo.getOriginalRequest().toString().contains("v1/doc"))
            {
                request.headers().set("Authorization", "Basic cHJpbmNpcGVDHHEHDNvbTpwd2Q0dGVzdCE=");
            }
            return null;
        }
    });
}

After initiating the proxy, and running the test in Selenium, an exception abruptly halts the process.

[LittleProxy-0-ProxyToServerWorker-4] ERROR org.littleshoot.proxy.impl.ProxyToServerConnection - (AWAITING_INITIAL) [id: 0x23fdf062, /192.168.1.103:49953 => www.html5rocks.com/216.239.38.21:80]: Caught an exception on ProxyToServerConnection io.netty.handler.codec.TooLongFrameException: HTTP content length exceeded 2097152 bytes.
at io.netty.handler.codec.http.HttpObjectAggregator.decode(HttpObjectAggregator.java:218) ~[browsermob-dist-2.1.0-beta-4.jar:?]
... (remaining error log)

[ProxyToServerConnection io.netty.handler.codec.TooLongFrameException: HTTP content length exceeded 2097152 bytes.]

In attempting to address this issue, I discovered that the HTTP content is too large, yet I am uncertain where to specify the content length. My goal is to resolve this exception smoothly.

Answer №1

If you're dealing with messages larger than 2097152 bytes, it's important to manually set the maximum request/response size.

To do this, simply include your request/response filter like so:

proxyServer.addFirstHttpFilterFactory(new RequestFilterAdapter.FilterSource(filter, 16777216)); // adjust buffer size as needed

For further details on this issue, check out: https://github.com/lightbody/browsermob-proxy/issues/372

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Jenkins consistently delivers positive outcomes with TestNG and Selenium testing frameworks

Recently I started using Jenkins and I am facing an issue with my builds. I am currently working on writing UI tests using Selenium, Java, and TestNG. My main concern is that despite having failing tests, Jenkins always displays 'Finished: SUCCESS&apo ...

What is the best way to create an xpath that can successfully match multiple conditions within an element?

Description: I am seeking to craft an Xpath that can accurately locate the specific condition within the div class = 'item_inside' Explanation: Picture this scenario: The webpage contains two item_inside classes. One class features the text Big ...

Manipulate iframe input element using Webdriver and Python

At the moment, I am faced with a unique challenge. I have an iframe element that is generated dynamically and needs to be saved as a variable. The structure of this iframe is quite detailed: <iframe id="iframe39993" class="green tea" src="...foo"> ...

"Automate the selection of the second radio button using Java with Selenium

Trying to select the second radio button using Java/Selenium. Dynamic ids are causing issues and XPath doesn't seem to work for some reason. Any assistance in understanding how to achieve this would be greatly appreciated. HTML <div class="form-r ...

Tkinter becomes unresponsive when running Selenium tasks

It's my first time delving into Tkinter. I decided to write a Python script for saving my pictures from Facebook. I wanted to create a GUI using Tkinker, but encountered an issue where the window freezes when clicking the start button. The process st ...

Search for an element using the partial fill attribute in Selenium using C#

I'm trying to find all the path elements that have a partial fill attribute of '#7cb5ec' Can someone explain how to do this using Xpath? <path fill="#7cb5ec" d="M 1015 130.02026666666666 C 1020.328 130.02026666666666 1020.328 138.020266 ...

WebDriverException was encountered while attempting to establish a connection with localhost/0:0:0:0:0:0:0:1:1941 using GeckoDriver and Selenium due to a java.net.ConnectException

I am currently facing an issue while trying to set up Eclipse for writing a basic automated test. Specifically, I am encountering difficulties in launching Firefox. Below is the code I have written along with the error stack that follows: Here's the ...

Issue with Selenium Webdriver - Unable to access and pick a value from Dropdown Menu

I'm struggling to successfully open and select a value from the Passengers Dropdown. Here is the code snippet I have been working with: public class SpiceJetTest { public static void main(String[] args) { System.setProperty("webdriver.ch ...

The removal of all cookies using `driver.manage().deleteAllCookies()` with Selenium does not function properly in conjunction with browser options

There seems to be an issue with the browser Options in Selenium where driver.manage().deleteAllCookies() is not working as expected. Here is a snippet of the code showcasing this problem. var profile = new firefox.Profile('./fProfile'); profile. ...

Utilizing Selenium to wait for a specific query to finish in Python

When working with UI automation using selenium and python3.x, I often encounter the need to wait for a specific query to finish before proceeding to the next step. However, in some cases, there are no elements available to use while the query is running, ...

What causes the break in Bamboo tasks once Protractor finishes?

Following the completion of my Protractor task, I am observing a 2-minute delay in my bamboo build. Below are the log details: [12/8/2015 5:10 PM] Agnew, Tyler: build 08-Dec-2015 16:45:24 Finished in 62.66 seconds build 08-Dec-2015 16:45:24 [32 ...

Encountering problems with scraping data using Python on the web

Looking for some advice as a beginner in Python and web scraping. I tried to write code to scrape quotes and the corresponding authors from https://www.brainyquote.com/topics/inspirational-quotes, but unfortunately, I didn't get any results. Here is t ...

Tips on employing the sendkeys function in selenium webdriverjs through promise chaining

Here is the coding snippet: driver.get(url).then(function(){ txtFnn = driver.findElement(webdriver.By.xpath(xpath)); return txtFnn; }).then(function(){ txtFnn.sendkeys("12345678"); }) Issue: An error occurred: Typ ...

Can someone please help me with automating the task of using Python to click on a button, download an Excel file, and then save it into a

Currently, I am working on a personal project that involves web scraping financial data and scheduling it to run daily using Windows Task Scheduler. This is the code snippet I'm using: import requests from selenium import webdriver from selenium.webd ...

What is the reason behind Gmail altering the id attributes of certain elements?

Here we have a snippet from Gmail, showcasing the "Compose" button. Note the id, it starts as ":il" when there are no unread messages. <div id=":il" class="aic"> <div class="z0"> <div class="T-I J-J5-Ji T-I-KE L3" tabindex="0" role="button" ...

Error: The loading status could not be determined due to an unknown issue

Seeking guidance as a newcomer to Selenium on how to troubleshoot the error detailed below. Selenium version - 3.5.3 ChromeDriver version - 2.29.4 Chrome version - 63 org.openqa.selenium.WebDriverException: unknown error: cannot determine loading statu ...

Choose the entire content and retrieve with the help of Selenium

During my website scraping process, I encountered a unique challenge. The text visible on the screen seemed to be generated from a database and was not present in either the inspect element or page source code. My attempt to manually select the text by pr ...

Exploring "Additional resources" using Selenium and Python

I am looking to extract text from the "Further reading" section of a Wikipedia article. My current code can open Google, input a request (such as 'Bill Gates'), and then find the URL of the corresponding Wikipedia page. Now I need help parsing th ...

Having trouble extracting information from Leboncoin due to a captcha obstacle when using Python and Selenium

Currently, I am utilizing selenium in combination with Python to extract data from the French website leboncoin.fr. Despite experimenting with various solutions recommended on StackOverflow, such as this one, I continue encountering difficulty bypassing th ...

Having trouble obtaining the XPath in Python using Selenium

I am currently trying to locate the xpath for this particular HTML structure. <div class="col-xs-6 pg-desc-section"> <p class="boldText">Jewelry</p> <p data-hostname="nikki stanzione" data- ...