Open daluu opened 12 years ago
See also related issue 87.
A good design would be to make WebDriverBackedSelenium as a class itself exposing Selenium RC API using WebDriver and then a separate WebDriverBackedSeleniumTestCase that uses the WebDriverBackedSelenium class to interface with PHPUnit.
At the current time, tests can be run with both the RC and the WebDriver API, against the same Selenium 2 server (PHPUnit_Selenium's test suite does that). So you can migrate one test case at the time by extending Selenium2TestCase instead of SeleniumTestCase, and of course changing the API calls. What advantages a special class would provide over the current situation?
I guess you're right in that there's no major advantage, however, it allows using existing PHP Selenium RC test code with WebDriver without having to rewrite against new API.
For those with a huge backlog of test cases to port, a WebDriverBackedSelenium provides a faster and more efficient way to migrate and see how things work (and how much stuff breaks) w/o having to spend time rewriting the tests. Just change reference to SeleniumTestCase to WebDriverBackedSeleniumTestCase (or equivalent) and then run tests and see how many fail and fix/tweak those (or rewrite those against pure WebDriver API).
It may also serve as another plus for picking PHP for Selenium 2 over other languages because Java (and maybe .NET) is the only one with a WebDriverBackedSelenium restricting choice and making Java the more popular option.
I'm currently working on a Selenium1 -> Selenium2 API translation class. I can send a patch in when I get the time.
At my current place of employ we run both Selenese (which uses the S1 API) and PHP based tests (where developers have used either S1 or S2 API). We have our own TestCase class that extends Selenium2TestCase and adds some extra functionality. So extending the one or the other is not an option for us. Also there are plenty places in the code base where the navigation to a test is done in PHP and then a Selenese file is called for the assertions or vica versa.
So I just wrote a class to do translation from S1 to S2 calls. It seemed the easiest way to fix everything at the time. This also saves the developers the time of having to update API calls to S2. It has the added bonus that things don't break when someone uses the S1 API because that's what they're used to.
I am in the process of changing jobs right now but I can send a pull request once things settle down. (The same goes for #175 as I have work done on that as well).
The only constraint is that new code should be covered with tests; in your case, you can reuse the tests from SeleniumTestCaseTest by duplicating the class and extending YourSeleniumTestCase instead of SeleniumTestCase.
There is no constraint on implementing all the API in one shot; starting with the basic calls is a good enough strategy.
Good luck for your new job!
Just an update to let you know I have not forgotten my commitment to this issue.
The transition to my new employer when well, unfortunately I've had a bad case of pneumonia in January and I've been struggling with my health since then. Things are almost at a place where I can be productive again. Circumstances allowing I will dive back into this issue in the coming month. I'll send a pull request when I have everything stitched up.
@potherca care about your health and don't worry about commitments, this is not a for-profit project and no one is pushing you to ship. Hope you are well.
At the time, after my health issues were resolved, I didn't work with Selenium in PHP anymore, so the code was never posted.
Recently, almost ten years later, I was contacted about this issue regarding legacy code. So, I've cleaned up the code I had and posted it here: https://gist.github.com/Potherca/9326c074d3451ddc0161a40765d79cf2
Maybe it will still be of use...
Nice to see issue 34 is accepted and worked on. Adding on to that, I think there should be a WebDriverBackedSeleniumTestCase.
This will help users of the PHPUnit Selenium (RC) extension migrate tests to WebDriver with minimal changes to their existing codebase. They can then gradually migrate the API calls from RC to WebDriver.
Initially, may want to implement functionality locally. But in future, when Selenium project implements the WebDriverBackedSelenium functionality at the server side (JSONWireProtocol) can then use that for the PHP class implementation. I don't have the issue ID for that on Selenium project, but I do recall that discussion.
If this is already in the plan and existing issue opened, please mention it.
If not planned for main project, maybe someone can do this as part of forking this project.