【问题标题】:ElementNotInteractableException: Message: Element <button class="btn btn-outline-light btn-icons" type="button"> could not be scrolled into viewElementNotInteractableException:消息:元素 <button class=\"btn btn-outline-light btn-icons\" type=\"button\"> 无法滚动到视图中
【发布时间】:2022-12-04 11:27:29
【问题描述】:

I am trying to press a the download on this page

https://data.unwomen.org/data-portal/sdg?annex=All&finic[]=SUP_1_1_IPL_P&flocat[]=478&flocat[]=174&flocat[]=818&flocat[]=504&flocat[]=729&flocat[]=788&flocat[]=368&flocat[]=400&flocat[]=275&flocat[]=760&fys[]=2015&fyr[]=2030&fca[ALLAGE]=ALLAGE&fca[<15Y]=<15Y&fca[15%2B]=15%2B&fca[15-24]=15-24&fca[25-34]=25-34&fca[35-54]=35-54&fca[55%2B]=55%2B&tab=table

i am using python selenium with firefox and this is what i tried:

driver.set_page_load_timeout(30)
driver.get(url)
time.sleep(1)
WebDriverWait(driver, timeout=20).until(EC.presence_of_element_located((By.ID, \'SDG-Indicator-Dashboard\')))
time.sleep(1)
download_div = driver.find_element(By.CLASS_NAME, \'float-buttons-wrap\')
buttons = download_div.find_elements(By.TAG_NAME, \'button\')
buttons_attributes = [i.get_attribute(\'title\') for i in buttons]
download_button_index = buttons_attributes.index(\'Download\')
buttons[download_button_index].location_once_scrolled_into_view
buttons[download_button_index].click()```

i keep getting the same error:
ElementNotInteractableException: Message: Element <button class=\"btn btn-outline-light btn-icons\" type=\"button\"> could not be scrolled into view

eventho i am getting the correct element and i tried using js like this:
```driver.execute_script(\"return arguments[0].scrollIntoView(true);\", element)```

also did not work.

    标签: python python-3.x selenium web-scraping download


    【解决方案1】:
    【解决方案2】:
    猜你喜欢
    • 1970-01-01
    • 2019-12-02
    • 1970-01-01
    • 2011-08-30
    • 1970-01-01
    • 2019-02-19
    • 1970-01-01
    • 2014-01-03
    • 1970-01-01
    相关资源
    最近更新 更多