1、Asser类提供的断言

assertTrue(web对象.isSelected()):是Asser类提供的断言,web对象.isSelected()用于判断单选或者多选按钮是否被选中且返回值是true或者false 

例子:

import org.testng.Assert;
//是否启用
		WebElement wqy_n=fFinds(dr, By.name("product.enable")).get(0);
		if(!wqy_n.isSelected()){//该单选按钮未被选中时则点击选中
			wqy_n.click();
			//assertTrue
			Assert.assertTrue(wqy_n.isSelected());//断言
		  
		}else {
			System.out.println("单选按钮已被选中");
		}

例子:

String actual=fFind(dr, By.className("messager-body panel-body panel-body-noborder window-body")).findElements(By.tagName("div")).get(1).getText();
		    Assert.assertEquals("添加成功", actual);//判断是否与预期的值一样

 

 

 

 

相关文章:

  • 2022-02-18
  • 2022-12-23
  • 2021-12-08
  • 2021-11-01
  • 2021-04-10
  • 2021-04-08
  • 2022-02-13
  • 2022-01-09
猜你喜欢
  • 2022-01-23
  • 2022-12-23
  • 2022-01-08
  • 2021-07-07
  • 2022-12-23
  • 2021-12-13
  • 2022-01-29
相关资源
相似解决方案