Get element at position with Selenium
To do this, you must use JavaScript:
element = driver.execute_script("""
return document.elementFromPoint(arguments[0], arguments[1]);
""", x, y)
This assumes that x
and are y
set to integer values. The arguments you pass execute_script
after the first argument become arguments[0], arguments[1]
, etc. On the JavaScript side. (This is just plain old arguments
object . Selenium wraps JavaScript code that you pass execute_script
to functions.) element
Will be either an instance WebElement
or None
if nothing is found. According to
source to share