小编use*_*114的帖子

使用Selenium记录操作

关于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)

firefox selenium action record

10
推荐指数
2
解决办法
2万
查看次数

标签 统计

action ×1

firefox ×1

record ×1

selenium ×1