- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我希望能够像用户一样快速单击注销按钮两次?
WebElement logout = driver.findElement(By.id("dijit_form_Button_0_label"));{
if(logout.isDisplayed()){
logout.click();
我希望能够像用户一样在不到一秒的时间内单击注销按钮两次?这在 selenium webdriver 中可能吗?
最佳答案
编辑:
喜欢atri说,你可以按照This thread使用双击功能.
WebElement logout = driver.findElement(By.id("dijit_form_Button_0_label"));{
if(logout.isDisplayed()){
logout.doubleClick();
如果你不想使用doubleClick功能,我会推荐Selemium的ExplicitWait Selenium: Implicit and explicit Wait
如果您想手动执行此操作,可以使用 javascript Thread 和 selenium wait 在单击之间添加延迟。基于This thread
WebElement logout = driver.findElement(By.id("dijit_form_Button_0_label"));{
if(logout.isDisplayed()){
logout.click();
Thread.sleep(100);
logout.click();
}
Better way is to use ExplicitWaits which you means you will wait exactly as long as some action happens or some element gets rendered on the page. - petr-mensik
An explicit waits is code you define to wait for a certain condition to occur before proceeding further in the code. The worst case of this is Thread.sleep(), which sets the condition to an exact time period to wait. - Selenium
关于java - 如何在 Selenium Webdriver 中模拟鼠标双击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34681496/
我是一名优秀的程序员,十分优秀!