selenium报错集锦(自用,持续更新)

标签超范围

【Message: Element could not be scrolled into view】
当设置页面大小后(driver.set_window_size(480, 800)),可能会由于显示不全,导致找不到按钮,很神奇的操作,哈哈哈

安装浏览器驱动

【Message: ‘geckodriver’ executable needs to be in PATH.”】
详见http://blog.csdn.net/qq471011042/article/details/79514908

网页元素无法定位(NoSuchElementException: Unable to locate element)

未获取当前页面句柄,刷新下句柄就行了

time.sleep(2)
now_handle = driver.current_window_handle
print("nowhandle= "+ now_handle)
allhandle = driver.window_handles
for handle in allhandle:

    if handle != now_handle:
        print('错误handle:'+handle)
        c = driver.switch_to_window(now_handle)
        print('修正后:'+c)

猜你喜欢

转载自blog.csdn.net/qq471011042/article/details/79514995