mvysny / karibu-testing

Vaadin Server-Side Browserless Containerless Unit Testing
Apache License 2.0
111 stars 14 forks source link

Trying to get property value that was changed through callJSFunction from PolymerTemplate component #57

Closed fionnachan closed 3 years ago

fionnachan commented 3 years ago

Hello, thanks for creating Karibu! I have just started writing some tests with PolymerTemplate components and bumped into problems....

I am testing a polymer component. The value was set by calling a server-side method that invokes a JS method through getElement().callJsFunction(). The component itself is very basic - <tag-name>[[textValue]]</tag-name> I am trying to retrieve the textValue from this component after running the value-setting method in the Karibu test file:

@Test
public void componentTextTest() {
    assertEquals("", component.getTextValue());
    component.setTextValue("something");
    assertEquals("some thing", component.getTextValue());
}

getTextValue is supposed to return getElement().getProperty("textValue");

I feel like it's because Karibu couldn't run the JS function to change the text value.... Could you please suggest a way to handle this case? Thank you very much!

mvysny commented 3 years ago

Hi Fionna, thank you for reaching out :+1:

Unfortunately this is a hard limitation of Karibu-Testing: there is no browser and therefore no way of running JavaScript. If you need to call JavaScript, you will have to use Selenium or TestBench. I'll update the README shortly, to reflect this.

fionnachan commented 3 years ago

Ah.... Thank you