[英]How to store the time at which an action is performed in java
我是java和selenium的新手。 所以我的要求是當點擊一個按鈕時,我想記錄按鈕點擊發生在元素上的時間,並將該元素中的值(以H:mm格式)與某個值進行比較。
我必須記錄點擊下面元素的時間:
@Test(priority = 7)
public void selectRightNow() {
actions.moveToElement(driver.findElement(By
.xpath("//*[@id='tabpanel-t0-2']/tpr-send-associates-page/ion-content/div[2]/div/div/ion-row[4]/ion-col[1]/div[1]")));
actions.click();
actions.build().perform();
}
並在這里比較我在下面使用的當前時間:
Assert.assertTrue(element.contains((new SimpleDateFormat("h:mm a")
.format(new java.util.Date()).toString() + " to Clock-out")));
要獲得即時時間,您可以使用以下行..
Instant start = Instant.now();
(可從Java 8獲得)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.