0
I’m having a hard time... I have a page to manipulate with Selenium, my problem is Iframes. I access a main Iframe and within that main iframe I have other iframes to manipulate, my porblema is that I can’t get out of the first Iframe that access, to be able to manipulate another Iframes and the main Iframe.
    #frame principal
    Iframe = self.Web_Browser.find_element_by_xpath(
        '//*[@id="ModalCommand_modal"]/div/div/div[2]/iframe')
    self.Web_Browser.switch_to.frame(Iframe)
    try:
        # button folder
        self.Web_Browser.find_element_by_xpath(
            '//*[@id="Button"]/div/div[1]/div/span/div/span[2]/a').click()
        sleep(1)
    except Exception:
        self.Web_Browser.find_element_by_xpath(
            '//*[@id="Button-M"]/div/div[1]/div/span/div/span[2]/a').click()
    #iframe Folder
    def Frame():
        Iframe_folder = self.Web_Browser.find_element_by_xpath('//*[@id="Iframe_folder"]/div/div/div[2]/iframe')
        self.Web_Browser.switch_to.frame(Iframe_folder)
        self.Web_Browser.find_element_by_id('Resultado_SearchField').send_keys('dados')
        self.Web_Browser.find_element_by_id('Resultado_SearchButton').click()
        sleep(2)
        click = self.Web_Browser.find_element_by_xpath(
            '//*[@id="Resultado_Simpl"]/tbody/tr[1]/td[1]/a')
        print(click.is_displayed())
        try:
            ActionChains(self.Web_Browser).move_to_element(click).click(click).perform()
        except Exception as e:
            print('\tError: Nenhuma Pasta encontrada')
        self.Web_Browser.switch_to.default_content()
        sleep(1)
    Frame()
    self.Web_Browser.find_element_by_xpath('//*[@id="Button"]/div/div[2]/div/span/div/span[2]/a').click()
    print(elemento.is_displayed())
I get this mistake:
Selenium.common.exceptions.Nosuchelementexception: Message: Unable to locate element: //*[@id="Button"]/div/div[2]/div/span/div/span[2]/a
I have no idea why I can’t get out of this Iframe.