">python+selenium:点击页面元素时报错:WebDriverException: Message: Element is not clickable at point ,1372.5, 9.5. Other element would receive the click:

遇到一个非常郁闷的问题,终于解决了,

问题是这样的,NN网站的价格计划,每一个价格计划需要三连击才能全部点开,第一个房型的价格计划是可以正确三连击打开的,可是第二个房弄就不行了,报错说不是可点击的元素,具体错误如下:WebDriverException: Message: Element is not clickable at point (1372.5, 9.5). Other element would receive the click: <li ></li>

报这种不可点击的错误有这三种情况:https://stackoverflow.com/questions/11908249/debugging-element-is-not-clickable-at-point-error

逐一排除:

1) 点击的元素被其它元素遮挡,(不是,肉眼看没有被遮挡)

2) 元素没有加载出来就点击(也不是,我加了等待时间的,而且展开的加载很快的)

3)元素不在当前屏幕范围内(也不是,我将鼠标移动到了当前点击元素所在的位置了)

最后在网上搜到一篇文章:做点击操作时的错误WebDriverException: unknown error: Element is not clickable at point (958, 207).

https://blog.csdn.net/breiofsd/article/details/71170250#commentsedit

这里说,原因:用selenium模拟用户单击元素时,JS有一个操作鼠标悬浮的时候会对元素进行修改

解决办法:用JS来操作元素,

没想到真的解决了呢。^.^

将:
driver.find_element_by_xpath("//div[@class=\"room-item-inner room-item-wrapper\"][" + str(i) + "]//a[@class=\"js-expand-more\"]").click
改为:
button = driver.find_element_by_xpath("//div[@class=\"room-item-inner room-item-wrapper\"][" + str(i) + "]//a[@class=\"js-expand-more\"]")
driver.execute_script("$(arguments[0]).click()",button)

selenium+python使用js点击元素:https://blog.csdn.net/u012189659/article/details/38496059

其他参考:selenium 之Action Chains类:https://www.cnblogs.com/cnkai/p/7538267.html