[英]Verify more than one word with the expected result in Robotium Script
[英]How to verify if search result has more than one result?
誰能幫忙找到使用硒和TestNG的搜索結果不只一個的搜索結果。 方案如下:
現在,驗證搜索結果中是否有1個以上結果(> 1)。 以下是我想到的Assert.assertEquals(actual, expected, delta);
。 這是正確的方法嗎?
試試下面的代碼。 它獲取所有搜索結果,然后檢查計數是否大於1,然后進行相應打印。 :-
driver.get("http://www.amazon.in/");
driver.findElement(By.id("twotabsearchtextbox")).sendKeys("bagsasdfafds");
int count = driver.findElements(By.className("suggest_link")).size();
Assert.assertTrue(count>=1);
System.out.println("Count is greater than or equal to 1. Count is: "+count);//This line will ONLY be printed if the count is greater than or equal to 1.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.