I want to get the Id of an iFrame directly with Selenium Chromedriver in Python without Javascript if possible, but I don't know why is failing.
When I do this I get wrong Id result as shown below.
>>> driver.find_element_by_class_name("MyClass").id
u'5b6a-c153-4e7f-90b2-b7e45'
If I send the following Javascript command on Chrome Console I get the correct frame Id:
> document.getElementsByClassName('MyClass')[0].id
< "MyFrame89-0-bed65f30"
Now when I try to use the same Javascript command within driver.execute_script() it doesn't show anything.
>>> driver.execute_script("document.getElementsByClassName('MyClass')[0].id")
>>>
So, here I have 2 issues:
1- driver.find_element_by_class_name().id is not showing the correct Id
2- driver.execute_script() it doesn't show anything.
What I'm doing wrong?
Thanks for any help.
UPDATE
A sample html code is here https://jsfiddle.net/k3x9rsa6/1/
id? can you share the relevant HTML?idis an HTML attribute and not a class field. Try.get_attribute("id").