Omar Yacop
Omar Yacop

Reputation: 305

Element not identified when not being focus on chrome window in Selenium

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?

Upvotes: 1

Views: 66

Answers (1)

Prophet
Prophet

Reputation: 33361

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")

Upvotes: 1

Related Questions