NameError:未定义名称“等待" [英] NameError: name 'wait' is not defined

查看:33
本文介绍了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")))

这篇关于NameError:未定义名称“等待"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆