请帮助我使用 php webdriver 脚本测试 jquery 自动完成小部件。我是 webdriver 脚本的新手。
这是我的代码
require_once "./phpwebdriver/WebDriver.php";
require_once "./phpwebdriver/LocatorStrategy.php";
$webdriver = new WebDriver("127.0.0.1", "4444");
$webdriver->connect("chrome");
$webdriver->get("http://URL_TO_WEBSITE");
$webdriver->typeKeys("ELEMENT_ID_TO_FIND", "a");
for ((int) $second = 0;; $second++) {
if ($second >= 60) fail("timeout");
try { if ($webdriver.isTextPresent("apple")) break; } catch (Exception e) {}
Thread.sleep(1000);
}
$webdriver->mouseOver("/html/body/ul/li/a[. = \"apple\"]");
$webdriver->click("/html/body/ul/li/a[. = \"apple\"]");