Selenium 的两种不同语法结构

Two different syntax structure for Selenium

我正在使用 AutoHotkey to drive SeleniumBasic v2.0.9.0

我是 Selenium 的新手,一直在查看许多讨论如何在网页上 get/set 元素的不同页面。我注意到似乎有(至少)两种不同类型的语法格式。 这里有两个例子:

 1. driver.findElementByID("search_form_input_homepage").SendKeys("hello")
 2. driver.findElement(By.id("search_form_input_homepage")).SendKeys("hello")

在我的例子中,第一个有效,但第二个抛出错误 No such interface supported。我只是好奇第二个结构的起源。它来自Selenium 3吗?

这是您问题的答案:

  1. driver.findElementByID("search_form_input_homepage").SendKeys("hello") :通过@FlorentB维护的VBA模块使用。
  2. driver.findElement(By.id("search_form_input_homepage")).SendKeys("hello") :通过 Selenium 的 Java 绑定使用。

如果这回答了您的问题,请告诉我。