PlayWithMagic / PlayWithMagic.org

PlayWithMagic.org is a web application that catalogs magic tricks and helps magicians build shows.
http://playwithmagic.github.io/PlayWithMagic.org/
Apache License 2.0
2 stars 1 forks source link

Implement Fluentlenium Tests for Material #124

Closed marknelsonengineer closed 9 years ago

marknelsonengineer commented 9 years ago

Fluentlenium tests for Material are not working correctly. The page-fill design pattern we've been using will not work because a lot of state is maintained in the browser (which is bad for a variety of reasons -- but we are sacrificing speed for security). The simulated browser needs to 'click' on links/buttons to go from page to page. The browser emulator has this capability, but when I click #add-material it clicks the #submit button at the bottom of the page and we don't go where we need to go. I've tried several methods to get around this, including:

At this point, I'm going to let it go and move forward with today's deployment.

marknelsonengineer commented 9 years ago

I'd like to discuss this at our next team meeting. Here's what I've found out:

  1. The fundamental problem is that HTMLUNIT either does not support HTML5 or doesn't support all of HTML5.
  2. There's an important HTML5 feature we use in the Materials pages. It's the formaction attribute of button. Basically, we need two buttons on the form. One (the default Submit button) submits the Routine and you go back to listRoutine. The other button is to Add Material. This also needs to be a button because it needs to submit a form, but it has a different action. This action needs to tell the controller to go to the EditMaterial page.

Patrick: Maybe we can think of other ways of doing this...

...in any event, the HTMLUNIT browser driver does not honor the formaction tag and that's that.

SO, if we need to use formation, how do we make that work? I've found a new browser driver Chromium that does the trick. It's fairly easy to install, but I want to ask the team about it first.

The docs/install instructions are here: https://sites.google.com/a/chromium.org/chromedriver/getting-started

Basically, you:

  1. Make sure Chrome is installed in its default location (easy).
  2. Download an executable and put it in the path.

Side effects: For starters, it actually flashes the browser and you can see it 'typing' form content into it. It's a little flashy.

Anyway, let's discuss the pros and cons. The good news is: I got the test path to work.

marknelsonengineer commented 9 years ago

After reviewing potential solutions, we are not going to try and refactor the CreateRoutine page... and we will try to solve the problem in the test.

We looked at potential solutions from Dr. Johnson's HTMLUniv vs. FireFox vs. PhantomJS post.

FireFox - Hangs, just as Dr. Johnson said it would. PhantomJS - This hangs as well. I downloaded PhantomJS and run $ phantomjs --version from the command line. Even after telling OSX's Security & Privacy page to 'trust' this application, all I ever get from the command line is: Killed: 9. OK, fine. I try using it from IntelliJ, but the JUnit test hangs and eventually times out/fails. Time to move on. Chromium - I got this to work last night and demo'd it w/ Patrick today. We think we can move forward with this approach. I'll wire it in and write it up in the Wiki.

marknelsonengineer commented 9 years ago

The Fluentlenium tests work great with Chrome. We have a great foundation for fluid tests. Time to close.