Selenium python Error: element could not be scrolled into view

Use the following xpath and click on that.

element=WebDriverWait(driver,30).until(EC.element_to_be_clickable((By.XPATH,"//div[@class='ui-dialog-buttonset']/button[@class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only']/span[contains(.,'Continue')]")))
element.click()

If above click not work then try below one.

element=WebDriverWait(driver,30).until(EC.element_to_be_clickable((By.XPATH,"//div[@class='ui-dialog-buttonset']/button[@class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only']/span[contains(.,'Continue')]")))
element.location_once_scrolled_into_view
element.click()

or you can use javascripts executor to click.

element=WebDriverWait(driver,30).until(EC.element_to_be_clickable((By.XPATH,"//div[@class='ui-dialog-buttonset']/button[@class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only']/span[contains(.,'Continue')]")))
driver.execute_script("arguments[0].click();", element)

EDITED

Try the below code it is clicking on continue button where both continue and cancel button there.once you click on continue you will another continue button to click.The code i have updated from schedule app.

#Schedule appointment
ele1=WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'(//button[@class="jquiButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"Schedule")])[1]')))
driver.execute_script("arguments[0].click();",ele1)
#click on continue button
WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@class="twoButton continueButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"Continue")]'))).click()
#click on second continue button
WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"Continue")]'))).click()

EDITED Rest of the code.

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.common.action_chains import ActionChains
from selenium import webdriver
from selenium.webdriver.support.select import Select
import time

driver=webdriver.Chrome()
driver.get("https://tn.ibtfingerprint.com/")
driver.maximize_window()
WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@name="IN_PublicMenuSelection"]/span[contains(.,"Schedule a New Appointment")]'))).click()
time.sleep(5)
select=Select(driver.find_element_by_id("varAgency"))
select.select_by_value("OTHR")
WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@id="collectAgency"]/span[contains(.,"Go")]'))).click()
element=WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.ID,'varAppType')))
select=Select(element)
select.select_by_value("60")
WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@id="collectAppType"][contains(.,"Go")]'))).click()
time.sleep(10)

driver.find_element_by_id("varORI").send_keys("tnvc00047")
WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@id="collectORI"][contains(.,"Go")]'))).click()
WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@class="twoButton continueButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"yes")]'))).click()

elements=WebDriverWait(driver,40).until(expected_conditions.presence_of_all_elements_located((By.XPATH,'(//i[@class="icon checkbox fa fa-fw fa-square-o fa-2x"])[last()]')))
if(len(elements)>0):
   element=driver.find_element_by_xpath('(//div[@class="fieldentity"]//i[@class="icon checkbox fa fa-fw fa-square-o fa-2x"])[last()]')
   element.location_once_scrolled_into_view
   ActionChains(driver).move_to_element(element).click().perform()
   elements[0].click()
   driver.find_element_by_css_selector("div.fieldentity div").click()
   driver.execute_script("arguments[0].click();",element)
   element1=WebDriverWait(driver, 40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@class="jquiButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"Go")]')))
   driver.execute_script("arguments[0].click();", element1)

time.sleep(10)
driver.find_element_by_name("IN_varLocZipCode").send_keys("37204")
WebDriverWait(driver,40).until(expected_conditions.presence_of_element_located((By.XPATH,'//button[@class="jquiButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"Go")]'))).click()
ele1=WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'(//button[@class="jquiButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"Schedule")])[1]')))
driver.execute_script("arguments[0].click();",ele1)
time.sleep(10)
WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@class="twoButton continueButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"Continue")]'))).click()
WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"Continue")]'))).click()

This Code is working fine on chrome browser and windows 10 OS.I have tested couple of times.


from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium import webdriver
from selenium.webdriver.support.select import Select


driver=webdriver.Chrome()
driver.get("https://tn.ibtfingerprint.com/")
driver.maximize_window()
WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@name="IN_PublicMenuSelection"]/span[contains(.,"Schedule a New Appointment")]'))).click()
element=WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.ID,'varAgency')))
select=Select(element)
select.select_by_value("OTHR")
WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@id="collectAgency"]/span[contains(.,"Go")]'))).click()
element=WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.ID,'varAppType')))
select=Select(element)
select.select_by_value("60")
WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@id="collectAppType"][contains(.,"Go")]'))).click()

WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.ID,'varORI'))).send_keys("tnvc00047")

WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@id="collectORI"][contains(.,"Go")]'))).click()
WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@class="twoButton continueButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"yes")]'))).click()


elements=WebDriverWait(driver,40).until(expected_conditions.presence_of_all_elements_located((By.XPATH,'(//form[@id="cjisAcknowledgementForm"]//div[@class="fieldentity"]//i[@class="icon checkbox fa fa-fw fa-square-o fa-2x"])[last()]')))

if(len(elements)>0):
   element=driver.find_element_by_xpath('(//form[@id="cjisAcknowledgementForm"]//div[@class="fieldentity"]//i[@class="icon checkbox fa fa-fw fa-square-o fa-2x"])[last()]')
   driver.execute_script("arguments[0].click();",element)
   element1=WebDriverWait(driver, 40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@class="jquiButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"Go")]')))
   driver.execute_script("arguments[0].click();", element1)

WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.NAME,'IN_varLocZipCode'))).send_keys("37204")

WebDriverWait(driver,40).until(expected_conditions.presence_of_element_located((By.XPATH,'//button[@class="jquiButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"Go")]'))).click()
ele1=WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'(//button[@class="jquiButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"Schedule")])[1]')))
driver.execute_script("arguments[0].click();",ele1)

WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@class="twoButton continueButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"Continue")]'))).click()
WebDriverWait(driver,40).until(expected_conditions.element_to_be_clickable((By.XPATH,'//button[@class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"]/span[contains(.,"Continue")]'))).click()

This error message...

selenium.common.exceptions.ElementNotInteractableException: Message: Element <span class="ui-button-text"> could not be scrolled into view

...implies that the WebDriver instance i.e. driver was unable to scroll the element within the Viewport to invoke click().


First of all, as your usecase is to invoke click() on the element, ideally instead of using presence_of_element_located() you need to use the ExpectedConditions as element_to_be_clickable() as follows:

WebDriverWait(driver, 1000000).until(EC.element_to_be_clickable((By.XPATH, '/html/body/div[5]/div[3]/div/button/span'))).click()

You can find a couple of detailed discussions in:

  • Message: Element could not be scrolled into view while trying to click on an option within a dropdown menu through Selenium
  • org.openqa.selenium.ElementNotInteractableException: Element could not be scrolled into view when trying to click a button

As an alternative, as per the error message, to scroll an element within the Viewport before invoking click() you can also use the Element.scrollIntoView() method.

You can find a detailed discussion in: - What is the difference between the different scroll options?


At this point it is worth to mention, the following methods:

  • move_to_element() from selenium.webdriver.common.action_chains
  • element_to_be_clickable() from selenium.webdriver.support.expected_conditions

will automatically scroll the element within the Viewport.

You can find a detailed discussion in: - How to scroll a webpage using selenium webdriver in Python without using javascript method execute_script()


This usecase

The button with text as Continue is within the Top Level Content but rendered within a Modal Dialog Box.

DevTools Snapshot:

ModalDialogBox

As the desired element is within a Modal Dialog Box, so to locate and invoke click() on the element you have to induce WebDriverWait for the element_to_be_clickable() and you can use the following Locator Strategy:

  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[starts-with(@aria-describedby, 'ui-id-')]//span[@class='ui-button-text' and text()='Continue']"))).click()
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    

DevTools Snapshot:

XPath