我是新來的硒。 我需要檢查系統中按鈕的可用性,並需要使用AssertEquals將其標記爲通過並失敗。用TestNG檢查按鈕
請幫幫我。
@Test
public void sellercheck() throws InterruptedException
{
Thread.sleep(2000);
driver.findElement(By.id("UserEvent")).click();
//String r=Read.getvalue().get(0);
//select the seller
driver.findElement(By.id("LegacyNumberCriterion")).sendKeys("123456");
driver.findElement(By.id("SuperUse")).click();
System.out.println("seller number entered");
try
{
if(driver.findElements(By.id("OrganizationBranchId")).size()!=0)
{
driver.findElement(By.id("button1")).click();
}
else
{
System.out.println("The button is not available for the seller");
}
}
catch(NoSuchElementException e)
{
System.out.println("Element does not exist!");
}
}
請提供更多信息:1.您的確切測試步驟是什麼? 2.什麼對你有用?顯示代碼。 3.你卡在哪裏? 4.提供錯誤堆棧跟蹤。 5.提供相關的HTML DOM。 – DebanjanB
1.如果有按鈕可用,測試用例已通過,或者如果失敗,則需要使用ID登錄後進行驗證。 – Bitz
我已添加代碼 – Bitz