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

  • SEARCH
  • Home
  • 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 7608025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:48:52+00:00 2026-05-31T00:48:52+00:00

So I’m writing a test framework for a large website, and am currently working

  • 0

So I’m writing a test framework for a large website, and am currently working on modeling the UI driver. I have a UI Session that abstracts a number of emulators and drivers for browsers and mobile devices. this object also holds state information about the browser session, including a history of page objects, the top of which is the current page. My problem is that I want my page objects to lazy load data from the browser (properties set up with getters that check whether we’ve extracted the data, if not, whether this is the current page, and if so, pulls the data from the browser and caches it in the page object), but that means they need access to the abstraction layer provided by the session.

The first idea of course was just sticking the session in the page, but that creates a circular reference, which is bad. I also considered trying to define multiple interfaces for page, but I couldn’t see how that would really work too well. What I really want is to be able to intercept the call in session then have session redirect the call down to page to a hidden getter that also takes session as an argument, but I haven’t been able to figure out how to do that.

Is there a good solution or design pattern that I could use here to get the info and access I need where I need it without having circular references or giving up lazy loading? I don’t want to make the interface more complicated by forcing users to sometimes call methods and sometimes call properties or members to access the same info (the idea is to hide the fancy footwork behind the scenes and make using the framework dead simple).

I actually do have a CurrentPage class that all it does is store the current_page in a class variable which is set by session on navigate events, so I suppose I could make current_page a magic global-esque accessor that would be the only way to actually get data off the page and have it use a special interface and store the session object as well, but that seems clunky to me.

Anyone have any suggestions?

  • 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-05-31T00:48:53+00:00Added an answer on May 31, 2026 at 12:48 am

    You said:

    “The first idea of course was just sticking the session in the page, but that creates a circular reference, which is bad.”

    But that’s not true. Circular references won’t get garbage collected instantly the way non-circular ones will, and __del__ methods won’t get called, but as long as you’re aware of both of those limitations and don’t have needs that conflict with them, circular references are fine. See:

    http://docs.python.org/reference/datamodel.html#object.__del__

    Having pages store a reference to the session should be fine.

    Edit: if session and page are in different files and circular imports become an issue, you can use an approach like this:

    # session.py
    import page
    class Session(object):
        def __init__(self):
            self.page_list = []
        def addPage(self, url):
            self.page_list.append(page.Page(self, url))
    
    # page.py
    class Page(object):
        def __init__(self, session, url):
            self.session = session
            self.url = url
    

    As long as you don’t need to construct Sessions inside of page.py you won’t need to import it at all, since there won’t be a need for capital-S Session (the class). If that changes, you can do something like:

    # page.py
    class Page(object):
        # ...
        def something(self):
            import session
            self.other_session = session.Session()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.