关于Selenium,我有一个半模糊的问题.我发现了一些使用FirefoxDriver执行操作的不同方法.我需要做的是重复用户在网页上执行的操作(单击链接,选中复选框等).是否有任何方法或方法组合允许我"记录"用户的行为?以下是我到目前为止执行操作的内容(您会注意到我已尝试使用WebDriverBackedSelenium和Actions类来执行操作)
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.interactions.Action;
public class MyReplayer {
public static void main(String[] args) throws Exception {
// The Firefox driver supports javascript
FirefoxDriver driver = new FirefoxDriver();
driver.get("http://www.cs.umd.edu");
List<WebElement> elements = driver.findElements(By.tagName("a"));
//WebDriverBackedSelenium driverBacked = new WebDriverBackedSelenium(driver, "http://www.cs.umd.edu");
Actions builder = new Actions(driver);
Action clickLink = builder.click(elements.get(100)).build();
clickLink.perform();
//driverBacked.click("document.getElementsByTagName('a')[100]");
}
}
Run Code Online (Sandbox Code Playgroud)