无法在Amazon EC2上运行python selenium webdriver脚本

2024-09-25 06:31:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试运行一个python脚本,在这个脚本中我打开一个网页并单击某个元素。但是脚本运行速度非常慢,并且随机出现异常。在

大多数时候它会停在队伍里 驱动程序=网络驱动程序Firefox()

消息-

selenium.common.exceptions.WebDriverException: Message: 'Can\'t load the profile. Profile ?Dir: /tmp/tmp4liaEq Firefox output: Xlib: extension "RANDR" missing on display ":1733".\n1403086712970\taddons.xpi\tDEBUG\tstartup\n1403086713204\taddons.xpi\tDEBUG\tcheckForChanges\n1403086713568\taddons.xpi\tDEBUG\tNo changes found\n'

有时- driver.find_element_by_xpath("//a[@id='some_id']") 返回错误:元素不可见,因此无法单击。在

同样的脚本在我有4GB RAM的系统上运行得很顺利。 (EC2系统规格~ 600mb内存)

我试着查看系统,结果“top”命令返回-

604332k total, 577412k used, 26920k free, 6616k buffers

我已经安装了firefox和xvfb,因为我正在运行firefox的headless


Tags: 网络脚本id消息元素网页系统驱动程序