I am implementing Vaadin Integration Test Case for the Menu Item as shown below
MenuBar.MenuItem homeMenu = menuItem.addItem("Home", null, null);
homeMenu.addItem("Dashboard", homeMenuCommand);
homeMenu.addItem("UserForm", homeMenuCommand);
MenuBar.MenuItem studentsAdmissionYear = menuItem.addItem("Admission Year", null, null);
studentsAdmissionYear.addItem("2018", myCommand);
studentsAdmissionYear.addItem("2019", myCommand);
studentsAdmissionYear.addItem("2020", myCommand);
studentsAdmissionYear.addItem("2021", myCommand);
studentsAdmissionYear.addItem("2022", myCommand);
And my Test Class is
package org.example;
import com.vaadin.testbench.TestBenchTestCase;
import com.vaadin.testbench.elements.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.net.MalformedURLException;
import java.net.URL;
import static org.junit.Assert.assertEquals;
public class ApplicationFullIT extends TestBenchTestCase {
WebDriver webDriver;
@Before
public void setUp() throws Exception {
setDriver(new ChromeDriver());
getDriver().get("http://localhost:8082/");
}
@Test
public void testMenu() throws MalformedURLException {
URL userFormUrl = new URL("http://localhost:8082/#!UserForm");
MenuBarElement menuBarElement = $(MenuBarElement.class).first();
menuBarElement.clickItem("Home","UserForm");
// assertEquals(getDriver().getCurrentUrl(),userFormUrl);
}
@After
public void tearDown(){
getDriver().quit();
}
}
The code
**MenuBarElement menuBarElement = $(MenuBarElement.class).first();
menuBarElement.clickItem("Home","UserForm");**
works till selection of Home menu but not working with the sub menu "UserForm"
Can you please help with a solution? I tried all possible solutions available by Googling but it is not helping me.