I'd like to capture the screenshot of the options that are displayed in the dropdown using selenium c# just like the image that is displayed below.
I've tried multiple ways to take the screenshot. Basically I've to expand the dropdown of the element to capture the screenshot. Here is what I've done
//#1
var element = Driver.FindElement(By.Id("carsId"));
Actions builder = new Actions(Driver);
builder.SendKeys(element, Keys.LeftAlt + Keys.Down).Build().Perform();
//#2
Actions act = new Actions(Driver);
act.MoveToElement(element).Build().Perform();
The first implementation to press Alt + Down keys worked manually when I've done on the site but didn't work through selenium. The second implementation didn't work either. I've also tried builder.ClickAndHold()
method as well.
And I've another question over here. Is it really possible for selenium to click and expand for a while until to grab the screen?
Any help would be greatly appreciated.