Selenium w/Python3 - AttributeError: 'str' object has no attribute 'tag_name' can you help me please

159 Views Asked by At
        capturarId = driver.find_element(By.tag_name,"iframe").send_keys('id')
        iframe = driver.find_element(by.xpath,"//iframe[@id='"+capturarId+"']")
        driver.switch_to.frame(iframe[0])

code and next error type object 'By' has no attribute 'tag_name' please can you help me

1

There are 1 best solutions below

3
Ketan Pardeshi On

You have given as iframe[0], iframe is Webelement not array hence you have to write in below way.

capturarId = driver.find_element(By.tag_name,"iframe").send_keys('id')
iframe = driver.find_element_by_xpath("//iframe[@id='"+capturarId+"']")
driver.switch_to.frame(iframe)