Testing Web Apps Using DRT

2019-08-05 17:35发布

问题:

I'm trying to use DRT for running acceptance tests.

Because it's an acceptance test I need to change the location to open the page under test. But of course, after I've done it my test script is gone.

I tried to use iFrames as a workaround, but Dart doesn't provide any means of getting the content of an iFrame. Which means that it's possible to load the page under test into an iframe, but it's impossible to get its html.

I've checked all the DRT tests in the Dart repo: http://code.google.com/p/dart/source/browse/#svn%2Fbranches%2Fbleeding_edge%2Fdart%2Ftests%2Fhtml

but it seems that none of them changes the location.

Is it possible to use DRT for running acceptance tests? Is there a workaround I didn't think of?

回答1:

We haven't come up with a good trick (redirection or iframes) to load the app as it is written and runs the test code on top of it. Instead, you could copy the entrypoint of an app and include the test code there, then run the modified app directly in DRT.

Here is an example from the web-ui codebase of a test that does this. This test runs the TodoMVC app and interacts with it:

https://github.com/dart-lang/web-ui/blob/master/test/data/input/todomvc_listorder_test.html

All we did is copy the original app's html, add the 'testing.js' script tag, and replace the dart script tag with the test code. It might be possible to create a script that automates what we do manually today, but we haven't done that.



标签: dart