Selenium Web Driver: Cannot Be Scrolled into View

Selenium element could not be scrolled into view

Just click on the parent element (with './..') and it'll work fine:

tos_checkbox = brower.find_element_by_xpath("//input[@id='mat-checkbox-1-input']/./..")
tos_checkbox.click()

Regards !

Element <option> could not be scrolled into view

If the option menu its not hidden inside a wrapper, example another dropdown menu or nested page try with actions moving to it.

from selenium.webdriver.common.action_chains import ActionChains

element = driver.find_element_by_xpath("//select[@name='city']")

actions = ActionChains(driver)
actions.move_to_element(element).perform()

or with javascript executor

driver.execute_script("arguments[0].scrollIntoView();", element)

Element(button) could not be scrolled into view

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)


Related Topics



Leave a reply



Submit