簡體   English   中英

如何使用webdriver / Java檢查字段旁邊的增加計數?

[英]How to check the increase count beside a field using webdriver/Java?

我有一個字段顯示旁邊的計數,每當一個新項目添加到字段時,計數增加一。 我希望每次都能獲得增加的計數,以確保將新項目添加到該字段中。 下面是顯示計數的字段

<span class="list-counting myone_qna_count">[2]</span>

您可以動態獲取計數並根據已知或以前的計數進行驗證。

By css = By.cssSelector(".list-counting.myone_qna_count");

//This should replace all the [] and return the count in String format
java.lang.String stCount = driver.findElement(css).getText().replaceAll("\\[|\\]", "");
//Parse to int so that it can be used to do the comparison
int count = Integer.parseInt(stCount);
System.out.println(count); //should be 2 now

//Do a comparison with known value here

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM