- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个问题:我想测试“select”和“input”。我可以像下面的代码那样写吗:原代码:
12 class Sinaselecttest(unittest.TestCase):
13
14 def setUp(self):
15 binary = FirefoxBinary('/usr/local/firefox/firefox')
16 self.driver = webdriver.Firefox(firefox_binary=binary)
17
18 def test_select_in_sina(self):
19 driver = self.driver
20 driver.get("https://www.sina.com.cn/")
21 try:
22 WebDriverWait(driver,30).until(
23 ec.visibility_of_element_located((By.XPATH,"/html/body/div[9]/div/div[1]/form/div[3]/input"))
24 )
25 finally:
26 driver.quit()
# #测试select功能
27 select=Select(driver.find_element_by_xpath("//*[@id='slt_01']")).select_by_value("微博")
28 element=driver.find_element_by_xpath("/html/body/div[9]/div/div[1]/form/div[3]/input")
29 element.send_keys("杨幂")
30 driver.find_element_by_xpath("/html/body/div[9]/div/div[1]/form/input").click()
31 driver.implicitly_wait(5)
32 def tearDown(self):
33 self.driver.close()
我想测试Selenium的“select”功能。所以我选择sina网站选择一个选项并在textarea中输入文本。然后搜索它。但是当我运行这个测试时,它有错误:
Traceback (most recent call last):
File "test_sina_select.py", line 32, in tearDown
self.driver.close()
File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 688, in close
self.execute(Command.CLOSE)
File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 376, in execute
return self._request(command_info[0], url, body=data)
File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 399, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "/usr/lib/python2.7/site-packages/urllib3/request.py", line 68, in request
**urlopen_kw)
File "/usr/lib/python2.7/site-packages/urllib3/request.py", line 81, in request_encode_url
return self.urlopen(method, url, **urlopen_kw)
File "/usr/lib/python2.7/site-packages/urllib3/poolmanager.py", line 247, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 617, in urlopen
release_conn=release_conn, **response_kw)
File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 617, in urlopen
release_conn=release_conn, **response_kw)
File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 617, in urlopen
release_conn=release_conn, **response_kw)
File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 597, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/lib/python2.7/site-packages/urllib3/util/retry.py", line 271, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=51379): Max retries exceeded with url: /session/2e64d2a1-3c7f-4221-96fe-9d0b1c102195/window (Caused by ProtocolError('Connection aborted.', error(111, 'Connection refused')))
----------------------------------------------------------------------
Ran 1 test in 72.106s
谁能告诉我为什么?谢谢
最佳答案
这个错误信息...
MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=51379): Max retries exceeded with url: /session/2e64d2a1-3c7f-4221-96fe-9d0b1c102195/window (Caused by ProtocolError('Connection aborted.', error(111, 'Connection refused')))
...表示调用 self.driver.close()
方法失败引发 MaxRetryError。
一些事情:
首先根据讨论 max-retries-exceeded exceptions are confusing 回溯 有点误导。为方便用户,请求包装了异常。原始异常是显示的消息的一部分。
请求从不重试(它为 urllib3 的 HTTPConnectionPool
设置了 retries=0
),所以如果没有 MaxRetryError,错误会更加规范 和 HTTPConnectionPool 关键字。因此,理想的追溯应该是:
ConnectionError(<class 'socket.error'>: [Errno 1111] Connection refused)
但在他的 comment 中又出现了 @sigmavirus24提到了...包装这些异常会产生出色的 API,但会带来糟糕的调试体验...
向前推进的计划是尽可能向下遍历到最低级别的异常并使用它。
最后,通过重写一些与实际连接被拒绝错误无关的异常来解决此问题。
甚至在调用 tearDown(self)
中的 self.driver.close()
之前, 中的 try{} block test_select_in_sina(self)
包含 finally{} 您已调用 driver.quit()
用于调用 /shutdown端点以及随后的 Web 驱动程序和客户端实例被完全销毁,关闭所有页面/选项卡/窗口。因此不再存在连接。
You can find a couple of relevant detailed discussion in:
在这种情况下,当您调用 self.driver.close()
时 python客户端无法找到任何事件连接来启动关闭。因此您会看到错误。
所以一个简单的解决方案是删除 driver.quit()
行,即删除 finally
block 。
根据 Selenium 3.14.1 的发行说明:
* Fix ability to set timeout for urllib3 (#6286)
合并是:repair urllib3 can't set timeout!
升级到 Selenium 3.14.1 后,您将能够设置超时并查看规范的 Tracebacks 并能够采取所需的操作。
一些相关的引用资料:
关于python - MaxRetryError : HTTPConnectionPool: Max retries exceeded (Caused by ProtocolError ('Connection aborted.' , 错误 (111, 'Connection refused' ))),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56701983/
我正在尝试从数组元素中形成最大数。下面给出的我的实现在某些情况下工作正常,而在其他一些情况下它给出错误“来自 abort(3) (SIGABRT) 的中止信号”。为什么?帮帮我! #include
我见过许多具有如下所示的线程过程的示例。 private void ThreadProc() { while (serviceStarted) {
以下代码用于基本的循环链表,但是当一个人输入一个较大的n(例如8位数字)值时,它将引发“abort(3)(sigabrt)中止信号”错误。我不确定这意味着什么,并且希望就我的代码解决此问题提供一些指导
这个问题在这里已经有了答案: Why exactly should I not call free() on variables not allocated by malloc()? (7 个答案)
此文档页面在突出通知中指出,Delphi 中有两个中止指令。一种称为abort,另一种称为Abort。 http://docwiki.embarcadero.com/RADStudio/Tokyo/e
我正在尝试获取/构建V8,并且需要首先安装depot_Tools。在运行UPDATE_DEPOT_TOOLS时,我不断收到从错误开始的错误。而且我永远也想不出为什么/找不到调试底层GO代码的源代码。
我正在尝试获取/构建V8,并且需要首先安装depot_Tools。在运行UPDATE_DEPOT_TOOLS时,我不断收到从错误开始的错误。而且我永远也想不出为什么/找不到调试底层GO代码的源代码。
在索引数据库中升级数据库版本时出错。“请求被中止,例如通过调用 IDBTransaction.abort。” ConstraintError:事务中的变异操作失败,因为不满足约束。例如,对象存储或索引
我对C++编程不是很在行,但我真的解决不了这个问题。我的项目如下:使用TCP协议连接到WiFi服务器。服务器继续发送文本行:没问题。它系统地连接在一起。专用线程正在循环接收文本并将其显示在编辑窗口中。
每次用户输入内容时,我都会使用 $.get jquery 函数。我的函数如下所示 function checkField(va) { $.get( '/admin-tool',
这是我的代码,它接受一个整数 s 作为输入,它是我希望它处理的字符串数量,然后它接受 s 个字符串作为输入。对于它们中的每一个,它应该输出更大的字母字典排列,即最小的字母排列。问题是它编译得很好,但在
这个问题在这里已经有了答案: C++ terminate called without an active exception (6 个答案) 关闭 6 年前。 让我们谈谈下一个代码示例: #inc
如果输入字段的长度为空,我会尝试取消所有剩余的 AJAX 请求。但是,我看到这个错误: Uncaught TypeError: Cannot read property 'abort' of unde
代码(我的原始代码使用assert,但这是一个更短的sscce) #include int main() { abort(); return 0; } 编译器版本: $ g++ --
我有一个以前从未见过的东西的回溯。请参阅这些线程中的框架 2: Thread 31 (process 8752): #0 0x00faa410 in __kernel_vsyscall () #1
前言: 有时候,连接mysql的会话经常会异常退出,错误日志里会看到"got an error reading communication packets"类型的告警。本篇文章
我正在尝试调用C++ Java 中的方法编码。 我收到了Android NDK : Aborting. Stop当定义 Android.mk文件如下: LOCAL_PATH := $(call my-
这更多是出于个人好奇心/兴趣,而不是我试图解决的特定问题。 假设您有一个程序正在对用户提供的信息(例如搜索字符串)执行一些操作,这些信息会随着用户键入而改变。假设您想向用户显示与他们在任何给定时间输入
我们需要将我们的一些 UI 翻译成英文,问题出现了:我什么时候使用“Abort”,什么时候使用“Cancel”作为按钮文本?它们似乎可以互换,并且或多或少地翻译成德语(我们的来源)中的同一个词....
当使用从 jQuery.ajax 函数传回的 xhr 中止 ajax 请求时,firebug 显示它仍在尝试加载该请求。它不会阻止发出的任何更多请求,但也不会显示它曾经完成过请求。 这只是一个 Fir
我是一名优秀的程序员,十分优秀!