1

I'm trying to press a button that is in an iframe. I can't switch to it because it has no id and the name of it is being randomly generated. How could I switch to it without the name or id? I thought I could switch to it by its title but sadly I can't.

I tried this:

def pressbutton():
    time.sleep(3)
    WebDriverWait(chrome, 0).until(EC.element_to_be_clickable((By.XPATH,"(//div[contains(.,'Something')])[last()]"))).click()
    time.sleep(2)

    chrome.switch_to.frame("a-v5kdywa4uk15") #Its name that is being randomly generated
    chrome.find_element_by_xpath("//div[@class='Button']").click()

1 Answers1

1

Turns out you can find a specific Iframe by its xpath:

iframe = chrome.find_element_by_xpath("//iframe[@title='Your iframe Title']")
driver.switch_to.frame(iframe)