Can Python's selenium library play a test case saved as HTML
Question: I'd like to be able to write a Django
[LiveServerTestCase](https://docs.djangoproject.com/en/dev/topics/testing/?from=olddocs#django.test.LiveServerTestCase)
which runs a Selenium test that has been saved as HTML using the Selenium IDE.
The code might look something like this:

    
    
    from django.test import LiveServerTestCase
    from selenium.webdriver.firefox.webdriver import WebDriver
    
    class TestUserStories(LiveServerTestCase):
    
        @classmethod
        def setUpClass(cls):
            cls.selenium = WebDriver()
            super(MySeleniumTests, cls).setUpClass()
    
        def test_registration(self):
            # Note - 'run_html_test' doesn't exist
            self.selenium.run_html_test('selenium/registration.html')
    

This would allow our QA team (who don't speak python) to write tests using the
Firefox Selenium IDE and save them as HTML. Is this possible?

As far as I can tell, HTML is the best format to save the tests in as it
allows them to be edited in the IDE later on - exporting to python doesn't
allow this and also generates python that needs converting to work with the
Django LiveServerTestCase.


Answer: I started a project myself to build this sort of shim: to wrap existing HTML-
based Selenium tests with Python, without having to convert the existing
tests. It was for the same reason you state: a (client) testing team wanted to
write HTML Selenium tests, but we wanted to run them using Selenium RC. Here's
the link:

<https://github.com/jpstacey/PySelenese>

However, we mothballed the specific sub-project it was built for, so it hasn't
had any attention for a long time.

With regards to your specific request, writing a standalone LiveServerTestCase
isn't optimal, because you then lose Selenium's idea of having many test cases
within a suite, and a suite index.html to define it. PySelenese instead wraps
the whole test suite and runs all test cases within it, in the order that the
Selenium IDE would run it; but I admit that the code to do that isn't
currently very pretty and could be more Pythonic.

But this in theory could do what you want, so feel free to try it out, fork
the github project, make your own changes etc. The PySelenese layer currently
has limited support for many Selenium commands, but that's fairly extensible.

(Explicit disclaimer: PySelenese started as my own personal Github project.)

