php调用selenium,通过PHP exec()执行Selenium webdriver
我构建了一个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相关推荐
- vba调用linux shell,调用命令提示符并通过VBA中的Shell Exec执行命令
我试图在VBA Excel中使用Shell脚本在命令提示符上执行命令.当我在命令提示符下执行此命令时,它通过打印一个数字作为输出.但是当我在脚本中调用相同的命令时,它不会在消息框中显示此数字.调用命令 ...
- 调用Runtime.getRuntime().exec()执行Linux脚本导致程序挂住的问题分析
问题: 在Java程序中,通过Runtime.getRuntime().exec()执行一个Linux脚本导致程序被挂住,而在终端上直接执行这个脚本则没有任何问题. 原因: 先来看Java代码: pu ...
- 【Selenium Grid 分布式测试】Selenium Grid-简介
前言 一直想学习自动化测试,但是都没行动,业余时间学习零零碎碎并记录20210423. 9.Selenium Grid 分布式测试 Selenium Grid 分布式测试-Selenium Grid简 ...
- selenium无头浏览器_无头Selenium浏览器
selenium无头浏览器 重要要点 无头浏览器无需用户界面即可运行. 不再支持PhantomJS. JBrowser驱动程序是Java 8的低开销选项. 如果需要Java 11支持,所有当前的Jav ...
- selenium IDE命令全手册/Selenium reference中文版
selenium IDE命令全手册 selenium IDE命令全手册 概念 三类命令 命令形式 pattern string-match patterns 元素定位器 Element Filters ...
- selenium基础教程_弹性Selenium基础设施
selenium基础教程 HelloFresh values a strong user experience, so proper testing is at the core of how we ...
- selenium第三课(selenium八种定位页面元素方法)
selenium webdriver进行元素定位时,通过seleniumAPI官方介绍,获取页面元素的方式一共有以下八种方式,现按照常用→不常用的顺序分别介绍一下. 官方api地址:https://s ...
- selenium速度_RPA UiPath和Selenium,谁是测试套件?
自动化领域的发展导致了技术的巨大发展.自动化测试已经成为各种实体功能背后的驱动力,因为它减少了手工测试的工作量,并且不太容易出错.自动化可以在早期阶段发现错误,最重要的是,它促进了批量测试,从而使业务 ...
- selenium查找文本_在Selenium中查找具有链接文本和部分链接文本的元素
selenium查找文本 Selenium中CSS定位器是一个基本概念,每个旨在使用Selenium执行自动化测试的测试人员都应该意识到这一点. 在Selenium中充分使用CSS定位器可以帮助您以更 ...
- Linux下rcS文件中sleep用法,对busybox工具rcS脚本中exec执行﹑后台执行和nohup执行的理解...
因为/etc/init.d/rcS脚本在/etc/inittab中以最高优先级第一个被init程序解析并使用daemon方式启动, ::sysinit:/etc/init.d/rcS 所以这样rcS脚 ...
最新文章
- mybatis教程--一对多查询
- 请回答一下Java中有几种线程池及实现过程?
- Jetpack 新成员 SplashScreen:为全新的应用启动效果赋能!
- 机器学习-决策树--基础知识总结
- VTD(Virtual Test Drive)
- DIV+CSS页面布局
- SuperMap的数据组织
- 计算机设置ip后提示未识别网络连接,win10设置正确的静态IP,但电脑显示未识别网络,怎么回事。求大佬们帮助啊...
- VOT Toolkit工具配置和使用--Python版本
- 实际运用1:正弦和余弦的动画图像生成(基于matplotlib的python数据可视化)
- 3dsmax导出html,3dsmax导出模型(怎么把3DMax文件导出CAD图纸?)
- 蓝桥杯及其搜索算法总结
- OpenVSwitch与OpenDayLight的连接过程
- drozer安装与使用
- 安卓开发问题之 Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication
- synplify pro和lattice lse综合同一段verilog代码时的区别
- simulink电机仿真学习 -根据转矩方程搭建速度环矢量模型
- 解决OUTLOOK删除邮件有PST文件大小不变
- 静电防护:消除静电的秘诀!
- 开题报告:基于java房产中介预约看房网站系统 毕业设计论文开题报告模板
热门文章
- Kubernetes-native 弹性分布式深度学习系统
- 这一团糟的代码,真的是我写的?!
- 阿里高级技术专家:研发效能的追求永无止境
- CPU 被挖矿,Redis 竟是内鬼!
- 面试编程岗,期望40K,为什么老板给我翻倍?
- 【建议珍藏系列】如果你这样回答「什么是线程安全」,面试官都会对你刮目相看!...
- 云现场 | 别等到WiFi断了 才明白云管理网络的重要性
- 云有约 | 精华汇总
- 华为鸿蒙网络,这回真翻脸了?被谷歌“除名”,官宣鸿蒙手机版,华为:走着瞧...
- oracle list 分区详解,oracle的List分区及分区索引