I've a Selenium question.
I've tried, body y-axis position : driver.execute_script('return window.pageYOffset')
How to display y-axis position within a div?
I've a Selenium question.
I've tried, body y-axis position : driver.execute_script('return window.pageYOffset')
How to display y-axis position within a div?
To display the x-axis
and y-axis
position of any WebElement e.g. the Search Box within Google Home Page you can use the following solution:
Code Block:
driver.get("https://www.google.com/")
element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, "q")))
print(element.location)
Console Output:
{'x': 439, 'y': 184}
To print only the y-axis
you can use:
Code Block:
driver.get("https://www.google.com/")
element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, "q")))
location = element.location
x, y = location['x'], location['y']
print(y)
Console Output:
184