使用selenium webdriver时,必须双击网页上的按钮

时间:2017-08-25 13:10:17

标签: selenium-webdriver

我正在使用此代码点击按钮

driver.findElement(By.linkText("Sign up")).click();

我尝试使用:

new WebDriverWait(driver,30).until(ExpectedConditions.elementToBeClickable(By.linkText("Sign up"))) 

但它不起作用。

1 个答案:

答案 0 :(得分:0)

尝试此示例,因为您没有提及网址:

WebDriver driver =new FirefoxDriver();     
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://only-testing-blog.blogspot.in/2014/09/selectable.html");
WebElement ele = driver.findElement(By.xpath("//button[contains(.,'Double-Click Me To See Alert')]"));

//To generate double click action on "Double-Click Me To See Alert" button.
Actions action = new Actions(driver);
action.doubleClick(ele);
action.perform();

浏览此网址以了解详情:

http://www.software-testing-tutorials-automation.com/2015/01/double-click-on-button-using-actions.html