如何找到使用Selenium Web驱动程序(用于Chrome)从PHP下载的文件的路径和名称?

克洛伊

使用Selenium和Chrome驱动程序下载文件后,如何获取文件名?

该站点避免了该问题,但提供了一些简单案例的示例:http : //ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/

我的链接是一个JavaScript链接,它会弹出一个新窗口并自动下载文件,并且文件名是在服务器上动态生成的。

该站点建议更改下载位置,但对于Firefox:http : //elementalselenium.com/tips/2-download-a-file

它列出了所有命令行选项,但没有一个用于设置下载过滤器:http : //www.ericdlarson.com/misc/chrome_command_line_flags.html

这个问题表明您可以更改目录,但是答案是Java格式,不适用于PHP:Chrome Web驱动程序下载文件

我尝试了以下操作,但出现了错误:

  $options = new ChromeOptions();
  $options->setExperimentalOption('download.default_directory', '\\temp');
  $capabilities = DesiredCapabilities::chrome(); // htmlUnitJS()
  $capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
  $driver = RemoteWebDriver::create($host, $capabilities, 5000);

PHP致命错误:未捕获的异常'UnknownServerException',消息为'未知错误:无法解析功能:chrome来自未知错误的选项:无法识别的chrome选项:download.default_directory

可能相关:https : //groups.google.com/forum/#! topic/ macenterprise/ cmSKIyzjQA8 https://github.com/facebook/php-webdriver/wiki/ChromeOptions

克洛伊

我将其更改为此,并且有效。它不喜欢\temp路径,它需要一个关联数组。

  $options = new ChromeOptions();
  $prefs = array('download.default_directory' => 'c:/temp/');
  $options->setExperimentalOption('prefs', $prefs);
  $capabilities = DesiredCapabilities::chrome(); // htmlUnitJS()
  $capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
  $driver = RemoteWebDriver::create($host, $capabilities, 5000);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用Chrome驱动程序通过Python和Selenium在指定位置下载文件

来自分类Dev

如何在使用chrome驱动程序/ firefox驱动程序时更改Webdriver中的文件下载位置

来自分类Dev

如何使用Selenium和Python在元素内部找到元素?

来自分类Dev

如何使用Xpath Selenium和Python找到span元素

来自分类Dev

如何通过Selenium Web驱动程序浏览和上传文件

来自分类Dev

无法使用Selenium Web驱动程序上传文件

来自分类Dev

如何使用Selenium和Chrome驱动程序在.net中的隐藏字段中键入文本

来自分类Dev

如何使用 selenium、chrome 驱动程序和 python 关闭新建的选项卡

来自分类Dev

如何使用Selenium Web驱动程序单击导航栏

来自分类Dev

如何使用Capybara和Selenium Web驱动程序发送密钥

来自分类Dev

使用python selenium下载文件,使用firefox驱动程序正确下载目录

来自分类Dev

带有Chrome驱动程序的Selenium网格(WebDriverException:驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置)

来自分类Dev

使用驱动程序类型“ Chrome”和指向chrome.exe路径的可执行批处理文件时,空手道驱动程序连接拒绝错误

来自分类Dev

不能将chrome驱动程序用于Selenium

来自分类Dev

Selenium Webdriver和Chrome驱动程序-无法运行Chrome驱动程序

来自分类Dev

Selenium Web驱动程序-无法找到元素

来自分类Dev

如何使用 selenium chrome 驱动程序在 Python 中按名称过滤网络调用条目?

来自分类Dev

如何使用Selenium Web驱动程序获取具有下一个div值的标签名称?

来自分类Dev

如何使用Selenium Web驱动程序获取具有下一个div值的标签名称?

来自分类Dev

是否可以使用Selenium Web驱动程序和一键构建Jenkins保存Adobe pdf文件

来自分类Dev

如何通过Selenium和Python使用classname属性找到最后一个Web元素

来自分类Dev

如何找到在Windows XP中使用随机名称创建启动启动驱动程序的源?

来自分类Dev

您如何使用Chrome驱动程序和所有现有的浏览器Cookie启动Selenium?

来自分类Dev

C#Selenium Web驱动程序和CSS:起点

来自分类Dev

如何使用Web Automation和Selenium跟踪文件的下载?

来自分类Dev

如何在python中的Selenium Chrome Web驱动程序中获取状态代码

来自分类Dev

如何配置Selenium Web驱动程序以在后台启动chrome浏览器

来自分类Dev

如何找到通过文字忽略了使用Selenium和XPath的情况下元素

来自分类Dev

如何使用Selenium和Python在https://www.shopdisney.com/中找到“创建帐户”元素

Related 相关文章

  1. 1

    使用Chrome驱动程序通过Python和Selenium在指定位置下载文件

  2. 2

    如何在使用chrome驱动程序/ firefox驱动程序时更改Webdriver中的文件下载位置

  3. 3

    如何使用Selenium和Python在元素内部找到元素?

  4. 4

    如何使用Xpath Selenium和Python找到span元素

  5. 5

    如何通过Selenium Web驱动程序浏览和上传文件

  6. 6

    无法使用Selenium Web驱动程序上传文件

  7. 7

    如何使用Selenium和Chrome驱动程序在.net中的隐藏字段中键入文本

  8. 8

    如何使用 selenium、chrome 驱动程序和 python 关闭新建的选项卡

  9. 9

    如何使用Selenium Web驱动程序单击导航栏

  10. 10

    如何使用Capybara和Selenium Web驱动程序发送密钥

  11. 11

    使用python selenium下载文件,使用firefox驱动程序正确下载目录

  12. 12

    带有Chrome驱动程序的Selenium网格(WebDriverException:驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置)

  13. 13

    使用驱动程序类型“ Chrome”和指向chrome.exe路径的可执行批处理文件时,空手道驱动程序连接拒绝错误

  14. 14

    不能将chrome驱动程序用于Selenium

  15. 15

    Selenium Webdriver和Chrome驱动程序-无法运行Chrome驱动程序

  16. 16

    Selenium Web驱动程序-无法找到元素

  17. 17

    如何使用 selenium chrome 驱动程序在 Python 中按名称过滤网络调用条目?

  18. 18

    如何使用Selenium Web驱动程序获取具有下一个div值的标签名称?

  19. 19

    如何使用Selenium Web驱动程序获取具有下一个div值的标签名称?

  20. 20

    是否可以使用Selenium Web驱动程序和一键构建Jenkins保存Adobe pdf文件

  21. 21

    如何通过Selenium和Python使用classname属性找到最后一个Web元素

  22. 22

    如何找到在Windows XP中使用随机名称创建启动启动驱动程序的源?

  23. 23

    您如何使用Chrome驱动程序和所有现有的浏览器Cookie启动Selenium?

  24. 24

    C#Selenium Web驱动程序和CSS:起点

  25. 25

    如何使用Web Automation和Selenium跟踪文件的下载?

  26. 26

    如何在python中的Selenium Chrome Web驱动程序中获取状态代码

  27. 27

    如何配置Selenium Web驱动程序以在后台启动chrome浏览器

  28. 28

    如何找到通过文字忽略了使用Selenium和XPath的情况下元素

  29. 29

    如何使用Selenium和Python在https://www.shopdisney.com/中找到“创建帐户”元素

热门标签

归档