Python Forum
Unable to switch out of nested frames into main page
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to switch out of nested frames into main page
#1
I have a program that does automated data entry on the PLM platform, ENOVIA, with specific information that I input. I'm using Selenium to navigate the webpage. There is a segment where the program has to enter 4 nested frames to click a certain element. It does that well and makes the necessary edits, the problem I'm facing is when I try to exit out of the frames back to the top of the HTML code to get back to the main page using switch_to.default_content(). For some reason, after it switches into the 4th child of the nested frames and makes these edits, I see that the window changes to only consist of these frames and whats within them, and nothing above the 1st parent frame. So switch_to.default_content() doesn't seem work.


This is the code that really matters, where it switches into the 4th and final frame "DSCObjectSummary" and makes these edits
    

def clickCheck(Method, Locator, elemName):
    #Add If Else to check for element availibility
    #Do Retries of searchess
    try:
        wait.until(EC.element_to_be_clickable((Method, Locator)))
        print(elemName + ' Clickable')
    except NoSuchElementException:
        print("Cannot Find Element")

...... Lots of code and comes to this point
    #Switching into 4 nested frames to click "EDIT DETAILS" Button
    wait.until(EC.frame_to_be_available_and_switch_to_it("content"))
    wait.until(EC.frame_to_be_available_and_switch_to_it("detailsDisplay"))
    wait.until(EC.frame_to_be_available_and_switch_to_it("portalDisplay"))
    wait.until(EC.frame_to_be_available_and_switch_to_it("DSCObjectSummary"))
    clickCheck(By.ID, 'DSCEditObjectSummary', "Edit Details")
    elemEdit = browser.find_element_by_id("DSCEditObjectSummary")
    elemEdit.click()

    #Click the Customer Dropdown
    clickCheck(By.ID, "PMCCustomerId", "Customer Dropdown")
    elemCust = browser.find_element_by_id("PMCCustomerId")
    elemCust.click()
    elemCust.send_keys("Ces")
    """Add If Conditions to check part number"""

    #Click Document Type Field
    clickCheck(By.ID, "PMCDocumentTypeId", "Document Type")
    elemDoc = browser.find_element_by_id("PMCDocumentTypeId")
    elemDoc.click()
    elemDoc.send_keys("MOD")

    """Add Check to see if part is Active/Obsol, if Obs, make Active"""

    #Click Dashnumber field
    clickCheck(By.ID, "PMCDashNumber", "Dash Number")
    elemDash = browser.find_element_by_id("PMCDashNumber")
    elemDash.click()
    elemDash.clear()
    elemDash.send_keys("-1")

    #Click Done Button
    clickCheck(By.CSS_SELECTOR, "button[class='btn-primary'][type='button']", "Done Button")
    elemDone = browser.find_element_by_css_selector("button[class='btn-primary'][type='button']")
    elemDone.click()

    browser.switch_to.default_content()
    time.sleep(20)
    
    
I have tried switching backwards from 4th to 1st parent frame then using switch_to.default_content() only to be thrown a NoSuchFrameException. All I want is to be able to get back out of the frames, just like I got into them, without changing/removing anything in the window and get back to the top level HTML.

I have realized that the window only changes when I try to interact with the elements in the 4th nested frame using commands such as send_keys() or click(). Other than that, if I stop at only accessing the frame, I am able to exit out of them perfectly fine back into the top level using default_content() and interact with other elements outside of these frames. Any ideas as to what could be causing this?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Selenium Parsing (unable to Parse page after loading) oneclick 7 6,000 Oct-30-2020, 08:13 PM
Last Post: tomalex
  Unable to click element in web page Kalpana 0 1,861 Jun-25-2020, 05:20 AM
Last Post: Kalpana
  use Xpath in Python :: libxml2 for a page-to-page skip-setting apollo 2 3,625 Mar-19-2020, 06:13 PM
Last Post: apollo
  malformed header from script 'main.py': Bad header: * Serving Flask app "main" anuragsapanbharat 2 4,528 Jun-12-2019, 07:26 AM
Last Post: anuragsapanbharat
  Sorting getting off, when I switch page Django 1.11 m0ntecr1st0 0 1,976 Feb-12-2019, 06:40 PM
Last Post: m0ntecr1st0

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020