首页 > 解决方案 > .location 和 getBoundingClientRect() 函数都返回相对于右上角的 x,y 坐标

问题描述

使用Selenium chrome 驱动程序定位Facebook.com 上登录按钮的坐标。所有其他字段位置都相对于左上角给出。

我努力了:

driver.execute_script('var rect = arguments[0].getBoundingClientRect(); return rect;', log_button))

log_button.location

标签: javascriptselenium-chromedriver

解决方案


推荐阅读