- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我想用 selenium 和 chrome 测试多个移动用户代理。我正在使用 python 3.6 并部署到 heroku。基于 http://chromedriver.chromium.org/mobile-emulation .
您可以在以下位置下载我用于 windows 和 heroku 的项目:
https://github.com/kc1/mobiletest
def some_long_calculation():
driver = create_chromedriver('kkk')
# driver = create_chromedriver()
driver.get("https://www.yahoo.com/")
.....
def create_chromedriver(ua=False):
options = webdriver.ChromeOptions()
CHROMEDRIVER_PATH = os.getenv('$HOME') or basedir+'/chromedriver.exe'
FLASK_CONFIG = os.getenv('FLASK_CONFIG')
if ua:
mobile_emulation = {"deviceName": "Nexus 5"}
options.add_experimental_option("mobileEmulation", mobile_emulation)
if FLASK_CONFIG and FLASK_CONFIG == "production":
CHROMEDRIVER_PATH = '/app/.chromedriver/bin/chromedriver'
GOOGLE_CHROME_SHIM = os.getenv('$GOOGLE_CHROME_SHIM') or 'no path found'
options.binary_location = '/app/.apt/usr/bin/google-chrome-stable'
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')
return webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, options=options)
2018-07-15T17:37:53.967643+00:00 app[web.1]: driver = create_chromedriver('kkk')
2018-07-15T17:37:53.967637+00:00 app[web.1]: png = some_long_calculation()
2018-07-15T17:37:53.967645+00:00 app[web.1]: File "/app/app/main/cl.py", line 120, in create_chromedriver
2018-07-15T17:37:53.967640+00:00 app[web.1]: File "/app/app/main/cl.py", line 123, in some_long_calculation
2018-07-15T17:37:53.967648+00:00 app[web.1]: return webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, options=options)
2018-07-15T17:37:53.967651+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
2018-07-15T17:37:53.967654+00:00 app[web.1]: desired_capabilities=desired_capabilities)
2018-07-15T17:37:53.967656+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 156, in __init__
2018-07-15T17:37:53.967659+00:00 app[web.1]: self.start_session(capabilities, browser_profile)
2018-07-15T17:37:53.967661+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 251, in start_session
2018-07-15T17:37:53.967669+00:00 app[web.1]: response = self.command_executor.execute(driver_command, params)
2018-07-15T17:37:53.967664+00:00 app[web.1]: response = self.execute(Command.NEW_SESSION, parameters)
2018-07-15T17:37:53.967667+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 318, in execute
2018-07-15T17:37:53.967672+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 472, in execute
2018-07-15T17:37:53.967674+00:00 app[web.1]: return self._request(command_info[0], url, body=data)
2018-07-15T17:37:53.967677+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 496, in _request
2018-07-15T17:37:53.967679+00:00 app[web.1]: resp = self._conn.getresponse()
2018-07-15T17:37:53.967682+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/http/client.py", line 1331, in getresponse
2018-07-15T17:37:53.967685+00:00 app[web.1]: response.begin()
2018-07-15T17:37:53.967687+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/http/client.py", line 297, in begin
2018-07-15T17:37:53.967695+00:00 app[web.1]: line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
2018-07-15T17:37:53.967690+00:00 app[web.1]: version, status, reason = self._read_status()
2018-07-15T17:37:53.967698+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/socket.py", line 586, in readinto
2018-07-15T17:37:53.967692+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/http/client.py", line 258, in _read_status
2018-07-15T17:37:53.967700+00:00 app[web.1]: return self._sock.recv_into(b)
2018-07-15T17:37:53.967712+00:00 app[web.1]: ConnectionResetError: [Errno 104] Connection reset by peer
from selenium import webdriver
mobile_emulation = { "deviceName": "Nexus 5" }
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)
driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities = chrome_options.to_capabilities())
最佳答案
ConnectionResetError: [Errno 104] 对等方重置连接
通常,当客户端在没有关闭连接的情况下突然终止时 RST packet
由底层操作系统的 TCP/IP 堆栈发送。 Python 将其转换为带有文本 的异常对等方重置连接 .根据您的错误堆栈跟踪,这意味着一次 self._read_status()
被调用(内部)Python 假定接收某些东西,但连接突然断开,Python 通过引发异常通知您此错误:
ConnectionResetError: [Errno 104] Connection reset by peer
"Connection reset by peer" is the TCP/IP equivalent of slamming the phone back on the hook. It's more polite than merely not replying, leaving one hanging. But it's not the FIN-ACK expected of the truly polite TCP/IP converseur.
options.add_argument("start-maximized"); // open Browser in maximized mode
options.add_argument("disable-infobars"); // disabling infobars
options.add_argument("--disable-extensions"); // disabling extensions
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage"); // overcome limited resource problems
return webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, options=options)
options.add_argument('--disable-gpu')
因为它仅适用于 Windows 操作系统。
Python Chrome Mobile Emulation
中的文档键和值对似乎是 "deviceName": "Google Nexus 5"
(不是 "deviceName": "Nexus 5"
)Remote()
通过以下任一方式——Remote()
通过 DesiredCapabilities()
:from selenium import webdriver
# import DesiredCapabilities was missing in your program
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
mobile_emulation = { "deviceName": "Google Nexus 5" }
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)
capabilities = DesiredCapabilities.CHROME
capabilities = options.to_capabilities()
driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities = capabilities)
Remote()
的类似讨论。通过 ChromeOptions()
在 How to add selenium chrome options to 'desiredCapabilities'? Remote()
通过 ChromeOptions()
:from selenium import webdriver
mobile_emulation = { "deviceName": "Google Nexus 5" }
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)
driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', options=chrome_options)
Remote()
的类似讨论。通过 ChromeOptions()
在 Remote WebDriver UnreachableBrowserException: Could not start a new session Webdriver.android
上的文档链接。 Getting started with Selendroid
上的文档链接。 driver.quit()
内tearDown(){}
优雅地关闭和销毁 WebDriver 和 Web Client 实例的方法。 @Test
. Linux kernels 2.6.17+ increased the maximum size of the TCP window/buffer, and this started to cause other gear to wig out, if it couldn’t handle sufficiently large TCP windows. The gear would reset the connection, and we see this as a “Connection reset by peer” message.
/etc/sysctl.conf
中:
127.0.0.1 localhost.localdomain localhost
关于python - 连接重置错误 : [Errno 104] Connection reset by peer and ERR_NAME_NOT_RESOLVED on heroku with mobile testing through Selenium,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51349410/
我删除数据库失败: mysql> 删除数据库 mydb; 错误 1010 (HY000):删除数据库时出错(不能 rmdir './mydb',errno: 39) 目录 db/mydb 存在于 my
据我所知,python的异常返回的errnos大部分与“linux/errno.h”中的errnos相同。但有时,事情并不像我期望的那样: 例如,当一个socket连接抛出一个socket.timeo
我们是否需要在调用函数之前将errno 重置为零?请参见下面的代码。现在的场景是 a_dest_path 是一个现有目录。但是当我执行代码时,它总是尝试 mkdir 但返回错误说该目录无法创建,因为它
在Red Hat Enterprise Linux Server release 5.7 上配置YUM本地源时,遇到了"[Errno 5] OSError: [Errno 2] No su
我正在尝试制作在线FPS游戏,到目前为止,它可以在我的本地网络上运行。我正在尝试做的是使其在全局范围内运作 过去,我曾尝试过使其他Python项目在全局范围内工作,但到目前为止,我还无法使其正常工作。
我希望获得有关在 Python 2.7 中使用urlopen时出现IOError: [Errno socket error] [Errno 10060]的更多信息。我正在使用我的个人 35MB/s 互
来自 linux 中 fwrite 的手册页, 描述 函数 fread() 从 stream 指向的流中读取数据的 nmemb 元素,每个 size 字节长,并将它们存储在 ptr 给定的位置。
我试图了解 glibc 如何在预处理器不替换 errno 符号的情况下初始化 errno。 我首先尝试自己基于csu/errno-loc.c实现了一个简单的版本和 csu/errno.c : myer
我看过这段代码: #if !defined(errno) extern int errno; #endif 所以我的问题是 errno 是 int 还是 macro ,因为使用 #if if 可以检查
errno.h 中的这 2 个 linux 错误有什么区别? 23 和 24 我尝试了 2 个不同的网站,但无法理解两者之间的区别。 [EMFILE] Too many open files. [EN
操作系统:Oracle Linux 6 [xxx@host /etc]$ uname -a Linux slc08yld 2.6.39-400.298.2.el5uek #1 SMP Mon Jan
什么样的库函数所面临的什么样的错误会影响errno并将其设置为非零值?在我下面的程序中,我打算使用 if(errno!=0) 作为条件来检查我使用的库函数是否正常运行,这是我发现的(见下面的代码):
我有一个 python 脚本,它创建一个 tar 文件,将文件移动到 tar 文件中,然后删除它们。 我可以毫无问题地手动运行脚本。但是当它从 cron 运行时,它失败了: IOError: [Err
我已经安装了 TensorFlow。当我下载 MNISTdataset 时,存在一个错误。谁能告诉我出了什么问题?非常感谢!错误详情如下: Python 2.7.9 (default, Apr 2
我正在尝试运行我的 python 代码,它显示以下内容: IOError: [Errno socket error] [Errno 54] Connection reset by peer 这是我的代
我正在将大量金融时间序列数据写入单个 CSV 文件。在一个实例中,我发现 to_csv 方法反复失败,但我终生无法弄清楚原因。在调用 to_csv 方法期间,一切都会挂起 10-15 分钟以上。在因错
我正在尝试从我的Python脚本打开文件recentlyUpdated.yaml。但当我尝试使用时:。我收到一个错误,内容是:。为什么?我怎样才能解决这个问题?
我正在尝试从我的Python脚本打开文件recentlyUpdated.yaml。但当我尝试使用时:。我收到一个错误,内容是:。为什么?我怎样才能解决这个问题?
我正在尝试从我的Python脚本打开文件recentlyUpdated.yaml。但当我尝试使用时:。我收到一个错误,内容是:。为什么?我怎样才能解决这个问题?
请解释以下程序中发生了什么。 我在程序的开头和结尾检查了 strerror(errno) 返回的地址,并确认它每次都返回相同的地址。然后一旦确定这一点,在第一种情况下我继续将相同的地址分配给 ptr,
我是一名优秀的程序员,十分优秀!