urllib3.exceptions.NewConnectionError:<urllib3.connection.HTTPConnection ...>:建立新连接失败:[Errno 111]连接被拒绝

时间:2019-06-03 09:40:26

标签: selenium selenium-webdriver selenium-chromedriver

为什么有人在硒中看到此错误?

<?xml version="1.0" encoding="UTF-8"?> <options xmlns="http://marklogic.com/appservices/search"> <search-option>unfiltered</search-option> <page-length>1</page-length> <term apply="term"> <empty apply="all-results"> </empty> <term-option>case-sensitive</term-option> <term-option>punctuation-insensitive</term-option> <term-option>diacritic-insensitive</term-option> </term> <grammar> <quotation>"</quotation> <implicit> <cts:and-query strength="20" xmlns:cts="http://marklogic.com/cts"> </cts:and-query> </implicit> <starter strength="30" apply="grouping" delimiter=")">(</starter> <joiner strength="10" apply="infix" element="cts:or-query" tokenize="word">OR</joiner> <joiner strength="30" apply="infix" element="cts:near-query" tokenize="word">NEAR</joiner> <joiner strength="30" apply="near2" consume="2" element="cts:near-query">NEAR/</joiner> <joiner strength="50" apply="constraint">:</joiner> <joiner strength="50" apply="constraint" compare="LT" tokenize="word">LT</joiner> <joiner strength="50" apply="constraint" compare="LE" tokenize="word">LE</joiner> <joiner strength="50" apply="constraint" compare="GT" tokenize="word">GT</joiner> <joiner strength="50" apply="constraint" compare="GE" tokenize="word">GE</joiner> <joiner strength="50" apply="constraint" compare="NE" tokenize="word">NE</joiner> </grammar> <sort-order direction="descending"> <score> </score> </sort-order> <constraint name="Collection"> <collection></collection> </constraint> <extract-document-data selected="include"> <extract-path>/URI</extract-path> </extract-document-data> </options>

何时使用各种功能?

1 个答案:

答案 0 :(得分:0)

请确保您尚未在某处终止会话。例如(在Python中);

urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0xsome_hex_address>: Failed to establish a new connection: [Errno 111] Connection refused

第二个WebDriverWait将失败,并显示错误消息,因为始终执行“ try”的“ finally”子句,因此驱动程序退出/已关闭。因此,后续的WebDriverWait失败。容易错过。

顺便说一句,在上面的示例中,您可以将“ finally:”更改为“ except:”,将其更改为“ only”,如果尝试失败,请执行driver.quit()。