未定义属性:stdClass :: $ ELEMENT

问题描述 投票:0回答:1

[我在youtube上找到了有关使用php在Windows中运行Selenium Webdriver的教程。我已经设置了xampp,安装了一些依赖项,以及诸如jar文件和geckodriver之类的其他依赖项。当我执行php代码时。我得到这个错误。

Notice: Undefined property: stdClass::$ELEMENT in C:\xampp\htdocs\sample1\phpwebdriver\WebElement.php on line 28

这是我的PHP代码:

<?php
/*
Copyright 2011 3e software house & interactive agency

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/


require_once "phpwebdriver/WebDriver.php";

$webdriver = new WebDriver("localhost", "4444");
$webdriver->connect("firefox");                            
$webdriver->get("http://google.com");
$element = $webdriver->findElementBy(LocatorStrategy::name, "q");
if ($element) {
    $element->sendKeys(array("hello" ) );
    $element->submit();
}

?>

[请有人帮助,我已经为这个错误工作了2天。我不知道该怎么办。预先感谢,如果有人回答了,请多谢。

php webdriver geckodriver
1个回答
0
投票

如果使用此WebDriver,应该没问题。

我认为您不能使用require_once = phpwebdriver/WebDriver,因为它应该像vendor/autoload.php中那样由this original example代替。

© www.soinside.com 2019 - 2024. All rights reserved.