NameError:未定义名称“等待"
我想知道是否有人可以帮助我.我正在尝试制作一个独立的网页抓取程序,除了等待命令外,一切似乎都在工作.在源代码编辑器中运行代码使其完美运行,但当我独立运行时,它会出错并且无法理解代码.
I was wondering if someone can help me out. I'm attempting to make a stand alone program for web scraping and everything appears to be working except the wait command. Running the code in a source editor makes it work perfectly but when I make the stand alone it errors out and doesn't understand the code.
wait.until(EC.frame_to_be_available_and_switch_to_it(driver.find_element_by_name('AppBody')))
EC = Expected Conditions
每当我单独运行它时,都会出现以下错误:
Whenever I run it as a stand alone though I get the following error:
Traceback (most recent call last):
File "Stand_Alone_CAS_Automation", line 57, in <module>
NameError: name 'wait' is not defined
[17344] Failed to execute script Stand_Alone_CAS_Automation
有什么建议吗?
此错误信息...
NameError: name 'wait' is not defined
...表示您在代码块中使用的变量 wait 未定义.
...implies that the variable wait which you have used in your code block was not defined.
您需要将变量 wait
定义为 WebDriverWait 的实例,或者您可以按如下方式引入 WebDriverWait:
Either you need to define the variable wait
as an instance of WebDriverWait or you can induce WebDriverWait as follows:
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.NAME,"AppBody")))