-->

Python Selenium Send Keys Giving Warning about siz

2020-08-21 02:35发布

问题:

I'm uploading content through python selenium binding element.send_keys(content), but I get a content size error.

My data will grow bigger.

Can you please give me a solution through which I can append the selected element in chunks rather than putting the complete and entire data to my selected field where I want to enter data?

I mean I want to put data to the selected element in chunks rather than putting it in in a single action.

By getting this kind of error, seems not good for my system and python as well.

But I'm not sure about it. Just want to know is it true?

Please give me the proper idea how can I send data through send_keys in chunks. It's very much necessary and needy to get its solution.

Thanks for your help.

[1560:9968:1211/012355:ERROR:latency_info.cc(157)] RenderWidgetHostImpl::OnSwapC
ompositorFrame, LatencyInfo vector size 161 is too big.
[1560:9968:1211/012357:ERROR:latency_info.cc(157)] RenderWidgetHostImpl::OnSwapC
ompositorFrame, LatencyInfo vector size 419 is too big.
[1560:9968:1211/012402:ERROR:latency_info.cc(157)] RenderWidgetHostImpl::OnSwapC
ompositorFrame, LatencyInfo vector size 640 is too big.
[1560:9968:1211/012422:ERROR:latency_info.cc(157)] RenderWidgetHostImpl::OnSwapC
ompositorFrame, LatencyInfo vector size 169 is too big.
[1560:9968:1211/012424:ERROR:latency_info.cc(157)] RenderWidgetHostImpl::OnSwapC
ompositorFrame, LatencyInfo vector size 448 is too big.
[1560:9968:1211/012428:ERROR:latency_info.cc(157)] RenderWidgetHostImpl::OnSwapC
ompositorFrame, LatencyInfo vector size 557 is too big.

回答1:

I know I'm late to the question but I recently had this problem. I managed to work around the issue by chucking the string I'm using for SendKeys into 128 chunks and sending them instead of the whole string.

I was working in C# but I'm sure you could port this code or if anyone else has a similar issue.

This is the chunking code

static IEnumerable<string> ChunksUpto(string str, int maxChunkSize) {
    for (int i = 0; i < str.Length; i += maxChunkSize) 
        yield return str.Substring(i, Math.Min(maxChunkSize, str.Length-i));
}

Taken from Splitting a string into chunks of a certain size



回答2:

@ulf-gjerdingen asked for answer in python for the same, I think it is answered in:

How do you split a list into evenly sized chunks?

The answer that I have choosen is using boltons.iterutils, install boltons with pip and then:

from boltons import iterutils
somelong_str = 'veeeeeeeeeeeeeeeeerrrrrrrrrrrrrrrrrrrrrrrrrrrrrrytttttttttttttttt loooooooooooong stringggggggggggggggggggggggggggggggggggggg to ensurrrrrreeeeeeeeeeeeeeeeeeeeeeeeee it will be chuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuncked'
iterutils.chunked(somelong_str, 128)

It will return a list of strings in this case.

To get more help from python console:

help(iterutils.chunked)