pythonseleniumreact-scroll

Scroll to find element nested inside - Senium with Python (using SeleniumLibrary)


pic1

pic2

I need to find element "16" , my project using driver = SeleniumLibrary

driver.open_browswer("..."_
driver.find_element ("//div[@id='react-select-4--value']").click()
driver.scroll_element_into_view("//span[contains(text(),'16']")
driver.find_element("//span[contains(text(),'16']").click()

I could click on the react-dropdown list but I can't use scroll_element_into_view to find that element then click()


Solution

  • option = driver.find_element("//span[contains(text(),'16')]")
    driver.execute_javascript("arguments[0].scrollIntoView();", option)
    

    Could you try this,