vaadin / starters

Issue repository for all the starter projects in https://vaadin.com/start
3 stars 0 forks source link

Starters tests have i18n problems #13

Open stefanuebe opened 4 years ago

stefanuebe commented 4 years ago

Describe the bug Downloaded the latest LTS bakery app starter and tried to run the StorefronViewIT integration test. The test failed due to my language setting. The required field error message is localized based on the browser's language setting, but the test is always checking for English error messages - mine is German and thus make the test fail.

Log

org.junit.ComparisonFailure: 
Expected :must not be blank
Actual   :darf nicht leer sein
<Click to see difference>

    at org.junit.Assert.assertEquals(Assert.java:115)
    at org.junit.Assert.assertEquals(Assert.java:144)
    at org.vaadin.stefan.testbench.StorefrontViewIT.testClearRequiredField(StorefrontViewIT.java:123)
    at org.vaadin.stefan.testbench.StorefrontViewIT.testTextFieldValidation(StorefrontViewIT.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

To Reproduce Steps to reproduce the behavior:

  1. Setup your OS to not use English.
  2. Download the bakery app starter.
  3. Configure your environment properly to run tests.
  4. Run the StorefrontViewIT.
  5. See error

Expected behavior The tests should be language independent or the chrome driver should be initialized to use "en" for tests.

Environment (please complete the following information):

Additional notes I'm trying to configure that by myself now for over an hour, it is not trivial.

Setting this for chrome driver didn't work, it is still showing German messages:

AbstractIT

    @Override
    public void setup() throws Exception {
        ChromeOptions chromeOptions = new ChromeOptions();
        Map<String, Object> prefs = new HashMap<String, Object>();
        prefs.put("intl.accept_languages", "en-us");
        chromeOptions.setExperimentalOption("prefs", prefs);
        chromeOptions.addArguments("--lang=en-US");
        WebDriver driver = new ChromeDriver(chromeOptions);

        setDriver(driver);
        getDriver().get("http://" + IPAddress.findSiteLocalAddress() + ":8080/");
    }
stefanuebe commented 4 years ago

Workaround: Switching my OS and Chrome language to english solved that.

samie commented 4 years ago

Would that be something that could be done in Chrome parameters?

anasmi commented 4 years ago

I am not sure this is a bug. More like an enhancement to make tests works on different locals. Unfortunately, I can't test this locally, but there seems to be a lot of discussions at https://stackoverflow.com/questions/18645205/set-chromes-language-using-selenium-chromedriver and some indeed suggested that the accepted answer(a code snippet similar to Stefan't) didn't work for them

samie commented 4 years ago

Maybe we should just change the test to use and override in English only?