I am experiencing a strange behaviour from selenium when running it on headless mode with Chrome webdriver. Up to now, I did not have this problem before to get text in headless mode, it always worked.
The reproduceble example is given bellow:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
options = webdriver.ChromeOptions()
#options.add_argument('--headless')
#options.add_argument('--no-sandbox')
driver = webdriver.Chrome(chrome_options=options)
driver.get("https://www.zoom.com.br/ar-condicionado/todos")
wait = WebDriverWait(driver, 10)
stores = wait.until(
EC.presence_of_all_elements_located((By.XPATH,
'.//span[@class="storeCount-txt"]')))
print(stores[0].text)
When I ran this peace of code the output is:
> em 14 lojas
However, when I run it on headless mode (remove #s), the output is empty:
> ""
Any ideas on what is going on?