hello, I am using Selenium RC on Firefox 2.0.0.14 on FreeBSD 6.2 with JRE 1.6.
When I am trying to fill some text fields longer than lets say 1000 characters, i get following error: 414 Request URI Too Large.
I assume that is due to the fact that Selenium driver (i mean main window which drives the child frame or child window) is being question with GET requests, and those request seem to be too large, is there any solution for this?
Regards, T. Kraus
Java server says:
20:30:52.420 WARN - null null null HttpException(414,Request URI Too Large,null)
20:30:53.413 INFO - Command request: click[//input[@value='Update'], ] on session 094b14dd86fe4923b0bd92d85dabe6c1
And i forgot to add I am using perl driver.
Will be very thankful for any responses
Okay, since there is no responses :P I had to hack it on my own.
This horrendal limit is due to Jetty FIXED non-modificable limit for max GET request.
Workaround for perl is splitting in chunks(same as somebody done with Python already)
My code ( i changed the function "type" in Selenium.pm) :
sub type {
my $self = shift;
my ($Locator, $Value) = @_;
my $MaxChars = 2000;
my $ValLen = length $Value;
if ($ValLen > $MaxChars) {
my $Pos = 0;
while ($Pos < $ValLen) {
my $Chunk = substr($Value, $Pos, $MaxChars);
$Chunk =~ s/\"/\\\"/g;
$Pos += $MaxChars;
my $JSCall = sprintf("selenium.browserbot.findElement(\"%s\").value += \"%s\";", $Locator, $Chunk);
$self->do_command("getEval", $JSCall);
sleep 2;
}
}
else {
$self->do_command("type", $Locator, $Value);
}
}
I've confirmed this is an issue with the Perl driver (see http://ttwhy.org/home/blog/2008/05/14/selenium-rc-per-session-extension-javascript/). I did not experience the issue using the Java driver.
Haw-Bin
Hi balrog
Could you point me to the Python fix please. I've tried replicating your code in python but I'm having some trouble with it.
def type(self,locator,value):
"""
Sets the value of an input field, as though you typed it in.
Can also be used to set the value of combo boxes, check boxes, etc. In these cases,
value should be the value of the option selected, not the visible text.
'locator' is an element locator
'value' is the value to type
"""
#My mod starts here. Taken from http://clearspace.openqa.org/message/43878
max_chars = 2000;
value_length = len(value)
if value_length > max_chars:
pos = 0;
while pos<value_length:
chunk = value[pos:max_chars]
chunk = chunk.replace('"', '\\"')
pos += max_chars;
js_call = 'selenium.browserbot.findElement("%s").value += "%s";' % (locator, chunk)
self.do_command("getEval", js_call)
time.sleep(2)
else:
self.do_command("type", [locator,value,])
Thanks
fintan.
If you're using a fairly recent Selenium RC, you can build the Python driver from trunk, which has the fix. See SRC-321 (http://jira.openqa.org/browse/SRC-321).
Haw-Bin
Thanks Haw-Bin Chai for the reply. How recent? I've 9.2 for the server and client. Would I need one of the release candidates?
9,2 should be fine for the Selenium server. You will have to build the python driver from trunk, though, as that was a very recent check-in. There are instructions here:
http://wiki.openqa.org/display/SRC/Developer%27s+Guide
Haw-Bin
Thanks Haw-Bin, I'll give it a shot.
fintan.
Hi all,
Thanks balrog for your code __, I like ruby and modified your code:
def type(locator,value)
@MaxChars = 2000
if !value.nil? then
@ValLen =value.size
end
if (@ValLen > @MaxChars) && (!value.nil?) then
@Pos = 0;
@JSCall = sprintf("selenium.browserbot.findElement(\"%s\").value = \"%s\";", locator, nil)
do_command("getEval", [@JSCall,])
while (@Pos<@ValLen)
@Chunk=value[@Pos,@MaxChars]
@Chunk=@Chunk.sub(/\"/,"\\\"")
@Pos += @MaxChars
@JSCall = sprintf("selenium.browserbot.findElement(\"%s\").value += \"%s\";", locator, @Chunk)
do_command("getEval", [@JSCall,])
sleep 0.1
end
else
do_command("type", [locator,value,])
end
end