robotframework / SeleniumLibrary

Web testing library for Robot Framework
Apache License 2.0
1.39k stars 765 forks source link

Capture Page Screenshot take screenshot without unrolled list of element "select" #427

Closed janduris87 closed 9 years ago

janduris87 commented 9 years ago

Hi, I need to take a screenshot of firefox page with unrolled element "select". After click on "select" element, full list of options is visible. When I take a picture with keyword "Capture Page Screenshot", this screenshot contain my "select" element... this element have focus also, but list of options is not visible on the picture. Why?

Example:

Go To    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select
Wait Until Element Is Visible    xpath=//article[@id='wikiArticle']/p[4]/select
Click Element    xpath=//article[@id='wikiArticle']/p[4]/select    #list of options is visible after click on element select
Capture Page Screenshot    TEST.png

On the left side of picture is screen created by "Capture Page Screenshot" and on the right side is screenshot which i want to take: test <SOURCE: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select>

I tried use keyword "Execute Javascript" and set default value of attribute "size" of element "select" to higher value (default size="1"), but this workaround isn't useful everytime.

Execute Javascript return (function(){jQuery('element').attr('size',"10");})();

zephraph commented 9 years ago

I have a feeling that this isn't something I'm going to be able to fix. It's likely that this is browser dependent behavior.

I'll investigate some other browsers to see how they function. I'll let you know if I come up with anything.

zephraph commented 9 years ago

After a bit of research this link is all I found.

Ultimately it boils down to the fact that the select box dropdown is actually a native element that exists outside the page (much like an alert). As such, there's no way for selenium to capture an image of it.

With that being said, I'm sure you could use a library like pyscreenshot to capture the image you're wanting to capture.

Sorry I wasn't able to help more.