Scroll a Drop-down until element is visible

Hello Guys,

Good Day to all of you.,

I am a self learner and I have come across an issue that I have not managed to find a comprehensive answer. I have an element which I am trying to click but it is inside a drop box and unless I scroll to that element it doesn’t become highlighted in the elements pane when I inspect it. There is no way to trace the element but with a xpath.

Any advise would be highly appreciated.

Thank you.

This is an HTML/JS question and not Python. Also, we would need to see your full code to better help you.

Oh no this is very much Python and in selenium.

    dropDown = browser.find_element(By.XPATH, "//*[text()[contains(.,'+995')]]")
    browser.execute_script("arguments[0].click();", dropDown)    

    #cCode = browser.find_element(By.XPATH, "//html/body/div/div/div/div/div/div/div/div/div/div/form/div/div/div/div/div/div/a/span[text()[contains(.,'კამბოჯა')]]")
    cCode = browser.find_element(By.XPATH, "//html/body/div/div/div/div/div/div/div/div/div/div/form/div/div/div/div/div/div/a/span[text()[contains(.,'+855')]]")
    browser.execute_script("arguments[0].scrollIntoView(true);", cCode)       

    browser.execute_script("arguments[0].click();", cCode)

What does the HTML file look like? This is still HTML related and not purely Python.

Under the country code I tried using the text contains but still it get’s only highlighted in inspection panel if I scroll to the element :frowning:


Yes chief, I did understand what you meant only a bit later. haha, sorry about that.


Any hand or advise please? :smiling_face_with_tear:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.