Reputation: 139
Is there any way to access protected method of abstract class?
In selenium webdriver i am unable to access protected method of class "SingleBrowserLocator"
http://selenium.googlecode.com/git/docs/api/java/index.html
Upvotes: 3
Views: 6146
Reputation: 718778
Like this:
public abstract class Foo {
protected void method() { ... }
}
public class Bar extends Foo {
public void method() {
super.method();
}
}
If you can't create a subclass (named as above, or anonymous), then reflection (or something that uses it) is your best option.
Upvotes: 1
Reputation: 284
There are 3 ways:
If the method is useful to you and made protected in an abstract class, probably the better or only correct choice is that you will have to implement a new subclass of it (the first choice above).
Upvotes: 1