Code example for HashSet

Methods: add, size

0
    collection.add("Brie");
    collection.add(7);
    long length = (Long) executeScript("return arguments[0].length", collection);
    assertEquals(collection.size(), length);
 
    collection = new HashSet<Object>();
    collection.add("Gouda");
    collection.add("Stilton");
    collection.add("Stilton");
    collection.add(true);
    length = (Long) executeScript("return arguments[0].length", collection);
    assertEquals(collection.size(), length);
  } 
 
  @Test 
  public void testShouldThrowAnExceptionIfAnArgumentIsNotValid() { 
    try { 
      executeScript("return arguments[0];", driver);
      fail("Exception should have been thrown"); 
    } catch (IllegalArgumentException e) {
      // this is expected