History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: SRC-54
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Dimitri Frederickx
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Selenium Remote Control

Make it possible to extend DefaultSelenium

Created: 19/Apr/06 02:16 AM   Updated: 18/Nov/08 09:28 AM
Component/s: Client Driver - Java
Affects Version/s: 0.7, 0.7.1, 0.8.0
Fix Version/s: 0.8.0

Original Estimate: 0.02h Remaining Estimate: 0.02h Time Spent: Unknown
Environment: Not relevant


 Description  « Hide
It should be possible to extend the class DefaultSelenium. This way you can add extra functionality and easily change the baseUrl of where to connect to with the launcher. In the test-program that i'm writing this is necessary and therefore i had to fix this issue. It's just a small fix that doesn't infect the current functionality.

The fix that has to be performed to make the extension possible is making the variables commandProcessor and launcher protected instead of private. This is much cleaner code that addes a lot of possibilities for other programmers.


Index: D:/workspaces/marvin/selenium/java/main/com/thoughtworks/selenium/DefaultSelenium.java
===================================================================
--- D:/workspaces/marvin/selenium/java/main/com/thoughtworks/selenium/DefaultSelenium.java (revision 939)
+++ D:/workspaces/marvin/selenium/java/main/com/thoughtworks/selenium/DefaultSelenium.java (working copy)
@@ -33,8 +33,8 @@
  */
 public class DefaultSelenium implements Selenium {
 
- private CommandProcessor commandProcessor;
- private BrowserLauncher launcher;
+ protected CommandProcessor commandProcessor;
+ protected BrowserLauncher launcher;
 
public static final String DEFAULT_SELENIUM_CONTEXT = "selenium-driver";
 


 All   Comments   Work Log   Change History      Sort Order:
Jimmy Larsson - 04/May/06 05:52 AM
I also would like to extend DefaultSelenium (since I want to add new asserts with user-extensions.js).

I think I nice way to do it could be to let the XML/XSL, that generates Java, generate an AbstractSelenium class. This class would have all the methods generated from javascript and one abstract method "protected CommandProcessor getCommandProcessor()".

A typical generated method would look like this:

public void assertTextPresent(String pattern) {
getCommandProcessor().doCommand("assertTextPresent", new String[] {pattern,});
}


Then we would write the DefaultSelenium class in plain java. The thing I like about this is that all javacode possible (constructors, start and stop) would be outside the XSL, and thus easier to change and patch. I also like to have a getter for the command processor, to be used by my subclasses with new asserts.

Hope you think this is helpful.

Dan Fabulich - 22/May/06 12:50 AM
Fixed in revision 1149. I'm not a big fan of the "protected" keyword, because "extends" can be a bit harmful, but, really, life is too short to worry about that sort of thing. For those who would extend DefaultSelenium, caveat extensor. http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html