Taking Screenshot of drop down contents

972 views
Skip to first unread message

Andy Smith

unread,
Oct 17, 2013, 3:52:39 AM10/17/13
to seleniu...@googlegroups.com
I am trying to take a screen shot that shows the contents of a drop down list with selenium webdriver on a selenium grid in C# on firefox with the 2.35 version of Selenium Webdriver. I am able to take the screenshot but the drop down list is not shown in expanded state despite it showing that way on screen.

Is it possible to take screenshots of the dropdown contents ?

To take the screen shot I am using     

Webdriver.GetScreenshot().SaveAsFile(fileName, ImageFormat.Png);

along with the following 

  public class ScreenShotRemoteWebDriver : RemoteWebDriver, IScreenshotEnabledWebDriver
    {
        public ScreenShotRemoteWebDriver(Uri remoteAdress, ICapabilities capabilities)
            : base(remoteAdress, capabilities)
        {
        }

        public Screenshot GetScreenshot()
        {
            // Get the screenshot as base64.
            var screenshotResponse = Execute(DriverCommand.Screenshot, null);
            var base64 = screenshotResponse.Value.ToString();

            // ... and convert it.
            return new Screenshot(base64);
        }
    }

Thanks

Andy
 

David Lai

unread,
Oct 21, 2013, 6:23:23 PM10/21/13
to seleniu...@googlegroups.com
I don't think it'll be possible for normal drop downs.  Since the overlay with the options you can choose from are displayed inside a native control and outside of the context of what selenium can work with.  For this, you'll need some separate process or tool that can capture the screenshot of the desktop or application it self.

If it's a custom (as in created using javascript and creative css styling) fake control, than it might be possible.  

if you need to just know what the options are available (like for debugging purposes).  you can do a find by tag name, "option" to get a reference to all the options under that select. Than perform a .text() on each to get the options available.  This might not be good for compliance testing, but will work if you just want to quickly check if the correct options are there.
Reply all
Reply to author
Forward
0 new messages