SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
345 stars 195 forks source link

Capturing improper screenshots for long pages in firefox #4499

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 4499

While capturing screenshots for long pages in our website if captured image is more
than 2000x2000 pixels images are not properly displayed

What steps will reproduce the problem?
1.Open a long web page example images page
2.capture the screenshot using selenium in firefox
3.capturing improper image,i have waited for more time even then its not coming properly

Excepted result should be proper image.
Its capturing proper screenshot for chrome, IE

Selenium version:Selenium.Remote.Driver 0.14 and
selenium-server-standalone-2.25.0.jar
OS:Ubuntu
Browser:Firefox 11.0
Browser version:11.0

CODE:
use Selenium::Remote::Driver;
require MIME::Base64;

my $driver = new Selenium::Remote::Driver('remote_server_addr' => 'localhost', 'port'
=> '4443',
                                          'browser_name' => 'firefox');          

print "namratha \n";
$driver->get("https://www.google.co.in/search?hl=en&q=very+very+long+page&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&biw=1024&bih=600&um=1&ie=UTF-8&tbm=isch&source=og&sa=N&tab=wi&ei=qkxEUKq_MMPMrQe1u4HIBQ#um=1&hl=en&tbm=isch&sa=1&q=icon&oq=icon&gs_l=img.3..0l10.4408.14519.0.14708.22.12.0.0.0.5.128.960.8j2.12.0...0.0...1c.cPaNOwzOjUM&pbx=1&fp=1&biw=1024&bih=600&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&cad=b&sei=n05EUKvZFsTwrQfc3oCACg");

sleep(40);
    open(FH,'>','/home/likewise-open/VITBDC/namrathar/Desktop/untitled folder/screenshot2.png');
    binmode FH;
    my $png_base642 = $driver->screenshot();
    print FH MIME::Base64::decode_base64($png_base642);
    close FH;

$driver->quit();

Reported by Namrathavr on 2012-09-03 06:46:58


lukeis commented 8 years ago

Reported by barancev on 2012-09-11 08:57:32

lukeis commented 8 years ago
Hi,

i'm able to reproduce your problem at selenium 2.32 + ff20, vista 32b.
But it is not Selenium problem.

This site draws items like images etc only after it scrolled to view it.
So you could easily to verify that selenium takes big (27Mb+, 1k x 17k pixels, 1GB
of memory used by FF) screenshot correctly by manual scrolling to bottom
or by automatic finding some web element at the bottom of page.

From my point of view it works as intendent - FF driver doesn't make screenshot correctly
if items are drawn on the scroll. I'm even not sure that any driver may take it.

Reported by a.u.savchuk on 2013-05-02 10:01:48

lukeis commented 8 years ago
Unfortunately the way that FirefoxDriver has to work to take screenshots means that
we will never be able to take a full canvas screenshot of elements not there. 

We work by taking the DOM and putting it in a hidden <canvas> element that not part
of the page and then ask for the base64 details of what is in the canvas. 

Sorry this doesn't meet your needs but as Alex has pointed out a work around for you.

David

Reported by david.burns@theautomatedtester.co.uk on 2013-05-07 12:52:21

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 18:16:07