我旁边有一个显示计数的字段,每当将新项目添加到该字段时,计数就会增加一.我想每次都增加计数,以确保将新项目添加到该字段中.以下是显示计数的字段
<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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。