hello my normally working code does not work in headless mode. Can you explain why?
from selenium import webdriver
import time
from selenium.webdriver.chrome.options import Options
option = Options()
option.add_argument('--window-size=1920,1080')
option.add_argument('--headless')
chromedriver = r'C:\Users\ozguc\Desktop\discord sesli\chromedriver.exe'
driver = webdriver.Chrome(chromedriver,options=option)
URL = 'https://discord.com/channels/875038857517731871/875038857517731874'
driver.get(URL)
driver.execute_script("""
function login(token) {
setInterval(() => {
document.body.appendChild(document.createElement `iframe`).contentWindow.localStorage.token = `"${token}"`
}, 50);
setTimeout(() => {
location.reload();
}, 2500);
}
login("token")
""")
time.sleep(10)
print("ok")
a = driver.find_element_by_xpath('//*[@id="channels"]/div/div[5]/div/div/div/a')
print("done")
a.click()
I want to automate entering the sound room normally my code works but when i pass it to headless=True it doesn't work