我构建了一个python脚本,它使用Selenium和Firefox加载一些网站并处理它们的内容。因为我想在PHP中使用该脚本的输出,所以我使用PHP的exec()函数。在

我的python测试脚本如下所示:from pyvirtualdisplay import Display

from selenium import webdriver

import sys

display = Display(visible=0, size=(800, 600))

display.start()

driver = webdriver.Firefox()

print("Driver started")

driver.quit()

display.stop()

当从命令行运行它时,我得到预期的“驱动程序启动”输出。在

但是,在这样的PHP脚本中运行它时:

^{pr2}$

python脚本产生以下错误:Traceback (most recent call last):

File "test.py", line 8, in

driver = webdriver.Firefox()

File "/usr/lib/python2.6/site-packages/selenium-3.4.3-py2.6.egg/selenium/webdriver/firefox/webdriver.py", line 152, in __init__

keep_alive=True)

File "/usr/lib/python2.6/site-packages/selenium-3.4.3-py2.6.egg/selenium/webdriver/remote/webdriver.py", line 98, in __init__

self.start_session(desired_capabilities, browser_profile)

File "/usr/lib/python2.6/site-packages/selenium-3.4.3-py2.6.egg/selenium/webdriver/remote/webdriver.py", line 188, in start_session

response = self.execute(Command.NEW_SESSION, parameters)

File "/usr/lib/python2.6/site-packages/selenium-3.4.3-py2.6.egg/selenium/webdriver/remote/webdriver.py", line 256, in execute

self.error_handler.check_response(response)

File "/usr/lib/python2.6/site-packages/selenium-3.4.3-py2.6.egg/selenium/webdriver/remote/errorhandler.py", line 194, in check_response

raise exception_class(message, screen, stacktrace)

selenium.common.exceptions.WebDriverException: Message: Unable to find a matching set of capabilities

我还应该提到,在命令行中,我尝试以root用户和另一个用户的身份运行脚本,两个用户都有效。web服务器正在使用“nginx”用户执行它,我无法在命令行上看到它,因为它被web服务器占用了。但是我假设,就像我的测试用户一样,nginx用户也应该拥有运行脚本所需的所有权限。在

Firefox版本:Mozilla Firefox 52.1.0

Selenium版本:3.4.3

Geckodriver版本:0.16.1

更新

尝试从php运行Firefox等可执行文件,但这也不起作用。在

php调用selenium,通过PHP exec()执行Selenium webdriver相关推荐

  1. vba调用linux shell,调用命令提示符并通过VBA中的Shell Exec执行命令

    我试图在VBA Excel中使用Shell脚本在命令提示符上执行命令.当我在命令提示符下执行此命令时,它通过打印一个数字作为输出.但是当我在脚本中调用相同的命令时,它不会在消息框中显示此数字.调用命令 ...

  2. 调用Runtime.getRuntime().exec()执行Linux脚本导致程序挂住的问题分析

    问题: 在Java程序中,通过Runtime.getRuntime().exec()执行一个Linux脚本导致程序被挂住,而在终端上直接执行这个脚本则没有任何问题. 原因: 先来看Java代码: pu ...

  3. 【Selenium Grid 分布式测试】Selenium Grid-简介

    前言 一直想学习自动化测试,但是都没行动,业余时间学习零零碎碎并记录20210423. 9.Selenium Grid 分布式测试 Selenium Grid 分布式测试-Selenium Grid简 ...

  4. selenium无头浏览器_无头Selenium浏览器

    selenium无头浏览器 重要要点 无头浏览器无需用户界面即可运行. 不再支持PhantomJS. JBrowser驱动程序是Java 8的低开销选项. 如果需要Java 11支持,所有当前的Jav ...

  5. selenium IDE命令全手册/Selenium reference中文版

    selenium IDE命令全手册 selenium IDE命令全手册 概念 三类命令 命令形式 pattern string-match patterns 元素定位器 Element Filters ...

  6. selenium基础教程_弹性Selenium基础设施

    selenium基础教程 HelloFresh values a strong user experience, so proper testing is at the core of how we ...

  7. selenium第三课(selenium八种定位页面元素方法)

    selenium webdriver进行元素定位时,通过seleniumAPI官方介绍,获取页面元素的方式一共有以下八种方式,现按照常用→不常用的顺序分别介绍一下. 官方api地址:https://s ...

  8. selenium速度_RPA UiPath和Selenium,谁是测试套件?

    自动化领域的发展导致了技术的巨大发展.自动化测试已经成为各种实体功能背后的驱动力,因为它减少了手工测试的工作量,并且不太容易出错.自动化可以在早期阶段发现错误,最重要的是,它促进了批量测试,从而使业务 ...

  9. selenium查找文本_在Selenium中查找具有链接文本和部分链接文本的元素

    selenium查找文本 Selenium中CSS定位器是一个基本概念,每个旨在使用Selenium执行自动化测试的测试人员都应该意识到这一点. 在Selenium中充分使用CSS定位器可以帮助您以更 ...

  10. Linux下rcS文件中sleep用法,对busybox工具rcS脚本中exec执行﹑后台执行和nohup执行的理解...

    因为/etc/init.d/rcS脚本在/etc/inittab中以最高优先级第一个被init程序解析并使用daemon方式启动, ::sysinit:/etc/init.d/rcS 所以这样rcS脚 ...

最新文章

  1. The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the argument
  2. python高级数据结构_Python高级数据结构(二)
  3. 服务器php环境一键配置,phpstudy一键配置服务器环境教程
  4. 泛亚凭借一粒薏米-农业大健康·田亚:对话农民丰收节交易会
  5. 深度学习方法(五):卷积神经网络CNN经典模型整理Lenet,Alexnet,Googlenet,VGG,Deep Residual Learning
  6. Oracle常用语句:分页查询语句的写法
  7. 学习vue第一篇记录
  8. URP中的2D Light光照在移动端不生效的问题
  9. 《零基础看得懂的C语言入门教程 》——(十三)socket服务端编写
  10. 154. Find Minimum in Rotated Sorted Array II
  11. data 谷歌浏览器更改user 路径_Chrome浏览器自定义设置个人信息存储路径
  12. R6饮料AK赛(NOIP模拟赛)/省选专练HDU 5713 K个联通块
  13. h5打开app_移动端产品比较分析:APP、小程序、H5
  14. linux 解压缩指令
  15. C语言main函数的参数及其返回值详细解析
  16. VAX Patch VA_X.DLL 安装位置的问题 for VS2008 , VS2010 , VS2011
  17. linux 安装arial字体,在CentOS中安装arial字体
  18. 收藏!示波器探头的选择与使用
  19. visualstudio 2017 工具栏隐藏解决办法
  20. 高德地图---路径规划---语音导航的开发

热门文章

  1. 阿里云MaxCompute被Forrester评为全球云端数据仓库领导者
  2. Alluxio完成C轮5000万美元融资,新设中国区总部力拓国内市场
  3. 神龙X-Dragon,这技术“范儿”如何?| 问底中国IT技术演进
  4. VMware竟然出了一款防火墙
  5. 云计算演进历程与模式 - 初识云计算知识专栏(2)
  6. 1024程序员节 | 我敢____,你敢么?Are you ready?
  7. java哪个城市的需求量大_4大互联网热门城市Java薪资情况,看完你想去哪个城市发展呢?...
  8. php创建多级栏目_用PHP实现多级树型菜单
  9. python异常处理try判断整数_Python 异常处理 try、except、raise
  10. linux死锁的例子,操作系统教程—Linux实例分析 孟庆昌 第8章 死锁new.ppt