21
21
import com .google .common .base .Supplier ;
22
22
import com .google .common .base .Suppliers ;
23
23
import com .google .common .collect .ImmutableMap ;
24
+ import com .google .common .primitives .Booleans ;
24
25
25
26
import com .thoughtworks .selenium .SeleneseTestBase ;
26
27
import com .thoughtworks .selenium .Selenium ;
@@ -90,12 +91,12 @@ private static ImmutableMap<String, CoreStepFactory> discover() {
90
91
isAccessor = false ;
91
92
}
92
93
93
- if (shortName != null && method . getParameterCount () < 2 ) {
94
+ if (shortName != null && isAccessor ) {
94
95
String negatedName = negateName (shortName );
95
96
96
97
factories .put ("assert" + shortName , ((locator , value ) -> (selenium , state ) -> {
97
98
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 ));
99
100
100
101
try {
101
102
SeleneseTestBase .assertEquals (expected , seen );
@@ -109,7 +110,7 @@ private static ImmutableMap<String, CoreStepFactory> discover() {
109
110
String locator = state .expand (loc );
110
111
String value = state .expand (val );
111
112
Object seen = invokeMethod (method , selenium , buildArgs (method , locator , value ));
112
- String expected = getExpectedValue (method , locator , value );
113
+ Object expected = getExpectedValue (method , locator , value );
113
114
114
115
try {
115
116
SeleneseTestBase .assertNotEquals (expected , seen );
@@ -123,7 +124,7 @@ private static ImmutableMap<String, CoreStepFactory> discover() {
123
124
String locator = state .expand (loc );
124
125
String value = state .expand (val );
125
126
Object seen = invokeMethod (method , selenium , buildArgs (method , locator , value ));
126
- String expected = getExpectedValue (method , locator , value );
127
+ Object expected = getExpectedValue (method , locator , value );
127
128
128
129
try {
129
130
SeleneseTestBase .assertEquals (expected , seen );
@@ -137,7 +138,7 @@ private static ImmutableMap<String, CoreStepFactory> discover() {
137
138
String locator = state .expand (loc );
138
139
String value = state .expand (val );
139
140
Object seen = invokeMethod (method , selenium , buildArgs (method , locator , value ));
140
- String expected = getExpectedValue (method , locator , value );
141
+ Object expected = getExpectedValue (method , locator , value );
141
142
142
143
try {
143
144
SeleneseTestBase .assertNotEquals (expected , seen );
@@ -233,7 +234,12 @@ private static String[] buildArgs(Method method, String locator, String value) {
233
234
return args ;
234
235
}
235
236
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
+
237
243
switch (method .getParameterCount ()) {
238
244
case 0 :
239
245
return locator ;
0 commit comments