我正在尝试切换到 selenium (Python) 中的 iframe。但是,无论我尝试什么,我都会不断收到错误消息。
iframes = driver.find_elements_by_tag_name('iframe')
print(len(iframes))
for iframe in iframes:
if 'ontouchmove' in iframe:
print(iframe)
driver.switch_to.frame(iframe)
这会产生错误 -
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: missing 'ELEMENT'
我也试过这个 -
iframes = driver.find_elements_by_tag_name('iframe')
print(len(iframes))
counter = 0
for iframe in iframes:
if 'ontouchmove' in iframe:
print(iframe)
driver.switch_to.frame(counter)
counter += 1
这会产生错误 -
selenium.common.exceptions.JavascriptException: Message: javascript error: frame.setAttribute is not a function
我不太确定我还能在这里做什么,有点迷失......任何帮助将不胜感激。
编辑:
iframes = driver.find_elements_by_tag_name('iframe')
print(len(iframes))
driver.switch_to.frame(iframes[0])
这会产生错误:
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: missing 'ELEMENT'