TA的每日心情 | 郁闷 2019-7-29 16:20 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
脚本如下:
# coding=utf-8
from selenium import webdriver
import time
driver = webdriver.Firefox()
driver.get("http://mail.163.com")
driver.implicitly_wait(30)
# 切换iframe
driver.switch_to_frame("x-URS-iframe")
driver.find_element_by_name("email").send_keys("123")
driver.find_element_by_name("password").send_keys("456")
报错如下:
C:\Python27\python.exe D:/test0729/iframe.py
Traceback (most recent call last):
File "D:/test0729/iframe.py", line 9, in <module>
driver.switch_to_frame("x-URS-iframe")
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 574, in switch_to_frame
self._switch_to.frame(frame_reference)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\switch_to.py", line 68, in frame
self._driver.execute(Command.SWITCH_TO_FRAME, {'id': frame_reference})
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchFrameException: Message: Unable to locate frame: x-URS-iframe
Stacktrace:
at FirefoxDriver.prototype.switchToFrame (file:///c:/users/admini~1/appdata/local/temp/tmpdehs06/extensions/fxdriver@googlecode.com/components/driver-component.js:10840)
at DelayedCommand.prototype.executeInternal_/h (file:///c:/users/admini~1/appdata/local/temp/tmpdehs06/extensions/fxdriver@googlecode.com/components/command-processor.js:12661)
at fxdriver.Timer.prototype.setTimeout/<.notify (file:///c:/users/admini~1/appdata/local/temp/tmpdehs06/extensions/fxdriver@googlecode.com/components/command-processor.js:625)
Process finished with exit code 1
为什么定位不到iframe???求大神指点 |
|