From cffff983b45b16760ba1cbb7b48ecc13247f43fd Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Mon, 18 May 2015 10:22:15 +0300 Subject: [PATCH] Fix MenuItemStyleRemoved test UI to work with IE8 Change-Id: I0987168f4531b8b548dbde03afd99da363ae31d4 --- .../menubar/MenuItemStyleRemoved.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuItemStyleRemoved.java b/uitest/src/com/vaadin/tests/components/menubar/MenuItemStyleRemoved.java index ea8bf5aec7..cf06836f94 100644 --- a/uitest/src/com/vaadin/tests/components/menubar/MenuItemStyleRemoved.java +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuItemStyleRemoved.java @@ -1,6 +1,8 @@ package com.vaadin.tests.components.menubar; +import com.vaadin.server.Page; import com.vaadin.server.VaadinRequest; +import com.vaadin.server.WebBrowser; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.JavaScript; @@ -8,6 +10,8 @@ import com.vaadin.ui.MenuBar; public class MenuItemStyleRemoved extends AbstractTestUI { + protected static final String MENUITEM_CLASS = "v-menubar-menuitem"; + @Override protected void setup(VaadinRequest request) { MenuBar menuBar = new MenuBar(); @@ -23,10 +27,17 @@ public class MenuItemStyleRemoved extends AbstractTestUI { addButton("Add styles", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { + String method = "getElementsByClassName('" + MENUITEM_CLASS + + "')"; + WebBrowser webBrowser = Page.getCurrent().getWebBrowser(); + if (webBrowser.isIE() + && webBrowser.getBrowserMajorVersion() == 8) { + method = "querySelectorAll('." + MENUITEM_CLASS + "')"; + } JavaScript.getCurrent().execute( - "var x=document.getElementsByClassName('v-menubar-menuitem');" + - " var i; for(i=0; i < x.length; i++)" + - " {x[i].className += ' custom-menu-item'};"); + "var x=document." + method + ";" + + " var i; for(i=0; i < x.length; i++)" + + " {x[i].className += ' custom-menu-item'};"); } }); } -- 2.39.5