I go to the frame on the site using the code
driver.SwithToFrame(0)
How can I find out now in focus the main site or frame?
To validate if the focus is on the Top Browsing Context or within the iframe, you can switch to the active_element
and then print the outerHTML
and you can use the following solution:
driver.switch_to.frame(0)
element = driver.switch_to.active_element
print(element.get_attribute("outerHTML"))