2121import com .google .common .base .Supplier ;
2222import com .google .common .base .Suppliers ;
2323import com .google .common .collect .ImmutableMap ;
24+ import com .google .common .primitives .Booleans ;
2425
2526import com .thoughtworks .selenium .SeleneseTestBase ;
2627import com .thoughtworks .selenium .Selenium ;
@@ -90,12 +91,12 @@ private static ImmutableMap<String, CoreStepFactory> discover() {
9091 isAccessor = false ;
9192 }
9293
93- if (shortName != null && method . getParameterCount () < 2 ) {
94+ if (shortName != null && isAccessor ) {
9495 String negatedName = negateName (shortName );
9596
9697 factories .put ("assert" + shortName , ((locator , value ) -> (selenium , state ) -> {
9798 Object seen = invokeMethod (method , selenium , buildArgs (method , locator , value ));
98- String expected = getExpectedValue (method , state .expand (locator ), state .expand (value ));
99+ Object expected = getExpectedValue (method , state .expand (locator ), state .expand (value ));
99100
100101 try {
101102 SeleneseTestBase .assertEquals (expected , seen );
@@ -109,7 +110,7 @@ private static ImmutableMap<String, CoreStepFactory> discover() {
109110 String locator = state .expand (loc );
110111 String value = state .expand (val );
111112 Object seen = invokeMethod (method , selenium , buildArgs (method , locator , value ));
112- String expected = getExpectedValue (method , locator , value );
113+ Object expected = getExpectedValue (method , locator , value );
113114
114115 try {
115116 SeleneseTestBase .assertNotEquals (expected , seen );
@@ -123,7 +124,7 @@ private static ImmutableMap<String, CoreStepFactory> discover() {
123124 String locator = state .expand (loc );
124125 String value = state .expand (val );
125126 Object seen = invokeMethod (method , selenium , buildArgs (method , locator , value ));
126- String expected = getExpectedValue (method , locator , value );
127+ Object expected = getExpectedValue (method , locator , value );
127128
128129 try {
129130 SeleneseTestBase .assertEquals (expected , seen );
@@ -137,7 +138,7 @@ private static ImmutableMap<String, CoreStepFactory> discover() {
137138 String locator = state .expand (loc );
138139 String value = state .expand (val );
139140 Object seen = invokeMethod (method , selenium , buildArgs (method , locator , value ));
140- String expected = getExpectedValue (method , locator , value );
141+ Object expected = getExpectedValue (method , locator , value );
141142
142143 try {
143144 SeleneseTestBase .assertNotEquals (expected , seen );
@@ -233,7 +234,12 @@ private static String[] buildArgs(Method method, String locator, String value) {
233234 return args ;
234235 }
235236
236- private static String getExpectedValue (Method method , String locator , String value ) {
237+ private static Object getExpectedValue (Method method , String locator , String value ) {
238+ Class <?> returnType = method .getReturnType ();
239+ if (returnType .equals (boolean .class ) || returnType .equals (Boolean .class )) {
240+ return true ;
241+ }
242+
237243 switch (method .getParameterCount ()) {
238244 case 0 :
239245 return locator ;
0 commit comments