2017-08-25 76 views
-1

我使用这个代码,点击一个按钮需要双击网页上的按钮,而使用硒的webdriver

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

我试着使用:

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

,但它没有工作。

+0

给我发[硒的webdriver的URL – iamsankalp89

+0

可能的复制Java代码使用网络驱动程序双击网格中的记录](https://stackoverflow.com/questions/21907007/selenium-webdriver-java-code-using-web-driver-for-double-click-a-record -in-A-GRI ) – JeffC

+0

你的代码在哪里尝试双击?您只需等待某个元素可点击,但不要点击该元素。 – JeffC

回答

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