/*-
 * #%L
 * Bobcat
 * %%
 * Copyright (C) 2016 Cognifide Ltd.
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package com.cognifide.qa.bb.aem.core.component.dialog.dialogfields;

import static org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable;

import java.util.List;

import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import com.cognifide.qa.bb.qualifier.PageObject;
import com.cognifide.qa.bb.wait.BobcatWait;
import com.google.inject.Inject;

/**
 * Default implementation of {@link TagBrowser}
 */
@PageObject(css = Locators.AUTOCOMPLETE_CSS)
public class DefaultTagBrowser implements TagBrowser {

  @FindBy(className = "coral3-Textfield")
  private WebElement input;

  @FindBy(xpath = Locators.ALTERNATE_LABEL_XPATH)
  private List<WebElement> label;

  @FindBy(css = ".coral3-Tag-removeButton")
  private List<WebElement> removeTagButtons;

  @FindBy(css = ".foundation-picker-buttonlist.coral3-Overlay.is-open")
  private WebElement firstResult;

  @Inject
  private BobcatWait bobcatWait;

  @Override
  public void setValue(Object value) {
    removeTagButtons.forEach((element) -> element.sendKeys(Keys.ENTER));

    input.clear();
    input.sendKeys(String.valueOf(value));

    bobcatWait.until(elementToBeClickable(firstResult));
    firstResult.click();
  }

  @Override
  public String getLabel() {
    return label.isEmpty() ? "" : label.get(0).getText();
  }
}

@@ -786,16 +786,69 @@
 kable;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.Arrays;%0A
 import j
@@ -1707,24 +1707,161 @@
 ct value) %7B%0A
+    List%3CString%3E tags = new ArrayList%3C%3E(%0A        Arrays.asList(String.valueOf(value).trim().replaceAll(%22%5C%5C%5B%7C%5C%5C%5D%7C%5C%5Cs%22, %22%22).split(%22,%22)));%0A%0A
     removeTa
@@ -1918,24 +1918,54 @@
 s.ENTER));%0A%0A
+    tags.forEach((tag) -%3E %7B%0A  
     input.cl
@@ -1971,24 +1971,26 @@
 lear();%0A    
+  
 input.sendKe
@@ -1996,33 +1996,16 @@
 eys(
-String.valueOf(value));%0A%0A
+tag);%0A  
     
@@ -2061,16 +2061,18 @@
 ));%0A    
+  
 firstRes
@@ -2080,24 +2080,32 @@
 lt.click();%0A
+    %7D);%0A
   %7D%0A%0A  @Over

Add multiple tag handling for TagBrowser