2 * Copyright 2000-2016 Vaadin Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
16 package com.vaadin.tests.components.nativeselect;
18 import org.junit.Assert;
19 import org.junit.Test;
20 import org.openqa.selenium.By;
21 import org.openqa.selenium.interactions.Actions;
23 import com.vaadin.testbench.parallel.BrowserUtil;
24 import com.vaadin.tests.tb3.MultiBrowserTest;
25 import com.vaadin.v7.testbench.customelements.NativeSelectElement;
27 public class NativeSelectsFocusAndBlurListenerTests extends MultiBrowserTest {
30 public void testFocusAndBlurListener() throws InterruptedException {
36 menuSub("Focus listener");
39 menuSub("Blur listener");
41 findElement(By.tagName("body")).click();
43 NativeSelectElement s = $(NativeSelectElement.class).first();
44 s.selectByText("Item 3");
45 getDriver().findElement(By.tagName("body")).click();
47 // Somehow selectByText causes focus + blur + focus + blur on
49 if (BrowserUtil.isChrome(getDesiredCapabilities())
50 || BrowserUtil.isPhantomJS(getDesiredCapabilities())) {
51 Assert.assertEquals("4. FocusEvent", getLogRow(1));
52 Assert.assertEquals("5. BlurEvent", getLogRow(0));
54 Assert.assertEquals("2. FocusEvent", getLogRow(1));
55 Assert.assertEquals("3. BlurEvent", getLogRow(0));
61 protected Class<?> getUIClass() {
62 return NativeSelects.class;
65 private void menuSub(String string) {
66 getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))
68 new Actions(getDriver()).moveByOffset(100, 0).build().perform();
71 private void menu(String string) {
72 getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))