Issue
So i am trying to open up a website and then navigating to a certain page that contains the page from which i have to scrape the data . i am able to give the input but before reaching the final submit button i get the error "selenium.common.exceptions.ElementNotInteractableException: Message: Element could not be scrolled into view". any ideas ?
i have tried to introduce the wait method but still it doesn't give useful results rather slows the site . down below is the code .
from selenium import webdriver
driver=webdriver.Firefox()
ok=driver.find_element_by_css_selector('#dropdownlistContentdrpState > input').send_keys('Chandigarh')
#time.sleep(5)
ok2=driver.find_element_by_css_selector('#dropdownlistContentdrpSchoolManagement > input').send_keys('Pvt. Unaided')
#driver.refresh()
time.sleep(10)
ok3=driver.find_element_by_css_selector('#btnSearch')
ok3.click()
time.sleep(4)
Solution
The error "selenium.common.exceptions.ElementNotInteractableException: Message: Element could not be scrolled into view"
implies that the element which your program was trying to interact with could not be scrolled into view.
To overcome that you can introduce WebDriverWait
and click or use element.location_once_scrolled_into_view
first and then click on the element.
Or you can use Javascript's executor
to click on the element.
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
WebDriverWait(driver,30).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"#btnSearch"))).click()
OR
ok3=driver.find_element_by_css_selector('#btnSearch')
ok3.location_once_scrolled_into_view
ok3.click()
OR
ok3=driver.find_element_by_css_selector('#btnSearch')
driver.execute_script("arguments[0].click();",ok3)
Answered By - KunduK
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.