Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8678657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:46:43+00:00 2026-06-12T20:46:43+00:00

I’m writing code to navigate a website (as practice before testing our website) with

  • 0

I’m writing code to navigate a website (as practice before testing our website) with Selenium. I’m attempting to iterate over values in 3 separate drop-down menus and retrieve an end-page with product data.

So far, I’m able to print data from the first first menu and associated data from the second, but only for the first element in the list created by the first menu…That is probably hard to follow, so consider this example:

DropdownA contains values:

A
B
C
D

When ‘A’ is selected, DropdownB is populated with values:

1
2
3

My goal is to cover the entire tree and return values:

A – 1,2,3

B – 2,3,4

C – 3,4,5

etc.

My script bombs after returning:

A – 1,2,3

Here is an example of my code:

from pyvirtualdisplay import Display
from selenium import webdriver
import time

display = Display(visible=0, size=(1024, 768))
display.start()
driver = webdriver.Firefox()
url = 'http://www.website.com'

driver.get(url)
driver.find_element_by_id('ctl00_ContentPlaceHolder1_pc_selector_selMake').click()
make_list = driver.find_elements_by_css_selector('#ctl00_ContentPlaceHolder1_pc_selector_selMake option')
for raw_make in make_list:
    if 'Select' in raw_make.text:
        continue
    make = raw_make.text
    print make
    raw_make.click()
    time.sleep(1)

    model_list = driver.find_elements_by_css_selector('#ctl00_ContentPlaceHolder1_pc_selector_selModel option')
    for raw_model in model_list:
        if 'Select' in raw_model.text:
            continue
        model = raw_model.text

        print ' ', model

driver.close()
display.stop()

The exact error is: selenium.common.exceptions.StaleElementReferenceException: Message: u'Element is no longer attached to the DOM'

I’m very new to Selenium, so if this is a silly question, forgive me. I’ve spent more time than I care to admit trying anything and everything that comes to mind, or that I’ve read online and nothing has helped (partially because most of the examples I’ve encountered are written in Java, and I’m not a Java guy…).

Any help, suggestions, solutions, resources, etc. is greatly appreciated.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:46:44+00:00Added an answer on June 12, 2026 at 8:46 pm

    Ultimately, it sounds like the DOM Elements you’re iterating over no longer exist. How could this happen, you may ask? I believe the issue arises in the following: You’re grabbing all tags within a drop-down by calling:

    driver.find_elements_by_css_selector('#ctl00_ContentPlaceHolder1_pc_selector_selMake option')
    

    You’re then iterating over each tag and clicking on each. My best guess would be the drop-down may be re-generated every time it is clicked on, therefore invalidating the objects you’re iterating over. Hence the successful first iteration, but every iteration thereafter rendering unsuccessful.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I am writing an app with both english and french support. The app requests
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.