nhungpham1512 / automation_testing_beginner

automation testing course aLinh
0 stars 0 forks source link

Đếm số lượng option trong listbox #7

Closed jacobvn84 closed 1 year ago

nhungpham1512 commented 1 year ago

Tham khảo tại đây

Câu hỏi: Làm sao để đếm được có bao nhiêu options trong listbox

Cách 01:

List days = jacob.asksFor( SelectOptions.of(By.name("DateOfBirthDay")) .describedAs("the number of days in month") );

    jacob.attemptsTo(
        Ensure.that(days).hasSize(32)
    );

Cách 02:

    int daysOfMonth = SelectOptions.of(By.name("DateOfBirthDay")).answeredBy(jacob).size();

    jacob.attemptsTo(
        Ensure.that(daysOfMonth).isGreaterThan(30)
    );

Cách 03:

Lưu giá trị vào một key thông actor.remember:

  jacob.remember("Total Days", SelectOptions.of(By.name("DateOfBirthDay")).describedAs("the days in month"));

Gọi và sử dụng bằng actor.recall

int totalDays= jacob.recall("Total Days");
assertThat(totalDays).hasSize(32);