cianurop
cianurop

Reputation: 1

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

        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

Upvotes: 0

Views: 167

Answers (1)

Ketan Pardeshi
Ketan Pardeshi

Reputation: 792

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)

Upvotes: 0

Related Questions