Home > other >  Element not identified when not being focus on chrome window in Selenium
Element not identified when not being focus on chrome window in Selenium

Time:08-16

I am trying to make a whatsapp bot, when the user opens other programs on the whatsapp window and this whatsapp window loses focus, it doesn't get some elements right. I tried to use headless but it now doesn't see any elements. Can someone help me?

CodePudding user response:

Have you set the screen size?
The default screen size for headless mode is significantly smaller than the default screen size in regular mode.
Try setting it as following:

driver.set_window_size(1920, 1080)

Or via the options parameters:

options.add_argument("--window-size=1920,1080")
  • Related