php - 使用 Selenium PHP 和 Laravel 执行期间未定义的类常量 'pageLoadStrategy' {"exception":"[object] 错误
问题描述
我正在构建 Web 测试代码,但第一次启动时出现错误
代码开头似乎有问题,但由于不知道而无法捕捉
-error
local.ERROR: Undefined class constant 'pageLoadStrategy' {"exception":"[object]
(Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Undefined class constant
'pageLoadStrategy' at /var/www/app/Service/SeleniumSet/Set.php:38)
-code
$host = env('SELENIUM_HOST'); // this is the default
$capabilities = DesiredCapabilities::chrome();
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
$capabilities->setCapability(ChromeOptions::pageLoadStrategy, 'nomal');
$this->driver = RemoteWebDriver::create($host, $capabilities, 7000);
$this->driver->executeScript("Object.defineProperty(navigator, 'plugins', {get: function() {return[1, 2, 3, 4, 5];},});");
return $this->driver;
解决方案
而不是应该是nomal
,有效地:pageLoadStrategy
normal
$capabilities->setCapability(ChromeOptions::pageLoadStrategy, 'normal');
参考
您可以在以下位置找到一些相关的讨论:
推荐阅读
- java - Wildfly 15 在不同机器上运行时未创建集群
- postgresql - 如何使用 pg_dump 在不同的数据库名称下备份/恢复?
- r - 如何在 R 中在自定义形状中创建堆叠条形图?(最好使用ggplot2)
- openlayers - OpenLayers 5在添加样式时不显示带有特征的矢量图层
- objective-c - CCCrypt 的 CCOptions 选项 = 0x3 是什么?
- node.js - Mongoose pre.save() 在创建记录时生成特定代码的问题
- javascript - 如何修复“ item.item_name 为空”
- java - 过滤器错误:尝试在空对象引用上调用接口方法“java.util.Iterator java.util.List.iterator()”
- c++ - 通过地图中的引用更新对象
- swift - 如何判断企业是否在午夜后营业