ponty / PyVirtualDisplay

Python wrapper for Xvfb, Xephyr and Xvnc
BSD 2-Clause "Simplified" License
714 stars 78 forks source link

Firefox menu not grabbed by waitgrab #67

Closed max00xam closed 2 years ago

max00xam commented 3 years ago

Firefox menu is not captured by waitgrab(), is there a way to get it?

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from pyvirtualdisplay.smartdisplay import SmartDisplay
import pyautogui, time

display = SmartDisplay(size=(1280, 720), bgcolor="black", backend="xvfb")
display.start()
driver = webdriver.Firefox(firefox_binary="./firefox/firefox-bin", executable_path="./geckodriver")
time.sleep(10)
pyautogui.moveTo(1130, 65)  # The firefox menu button position
pyautogui.click()
time.sleep(5)
display.waitgrab().save("screenshot.png")

screenshot

ponty commented 3 years ago

This is not a pyvirtualdisplay bug. pyvirtualdisplay will grab what is displayed. Your program doesn't open the menu. You can check it with backend="xephyr", the menu just disappears. I found the same problem with firefox here: "The dropdown menus in firefox do not stay open. It's like they flicker for a second and then disappear." https://unix.stackexchange.com/questions/617109/firefox-and-xorg-without-window-manager