I'm trying to find the correct location of an element in selenium but this is givin me some troubles, this is my code
from selenium import webdriver
from pynput.mouse import Button, Controller as MouseController
mouse = MouseController()
driver = webdriver.Chrome()
driver.maximize_window()
driver.set_page_load_timeout(30)
driver.get("https://stackoverflow.com/")
element = driver.find_element_by_xpath('//*[@id="mainbar"]/div[1]/h1')
x, y = element.location["x"], element.location["y"]
mouse.position = x, y
But i don't understand why it returns a position different from the correct element location