尝试使用页面对象menu.js从spec.js访问角度应用程序的菜单,但是在运行量角器时出现错误。失败:无法读取未定义的属性'click'
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost(MY_SERVICE_URL);
String json = new String("[{\"param1\": \"" + "param1Value" + "\",\"param2\": \"" + "param2Value" + "\"}]");
request.setEntity(new StringEntity(json));
request.setHeader("Content-Type", "application/json");
request.setHeader("Accept", "application/json");
try {
HttpResponse response = client.execute(request);
int responseCode = response.getStatusLine().getStatusCode();
BufferedReader rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
String output = rd.readLine();
System.out.println("Response code: " + responseCode);
System.out.println("Output: " + output);
} catch(Exception ex) {
System.out.println("Error");
}
client.getConnectionManager().shutdown();
答案 0 :(得分:0)
哇,您的测试风格有些陈旧。使用JS
的新功能要容易得多。
但是,您返回object
。取而代之的是返回element
。您可以返回函数,该函数将返回与您的代码样式有关的元素:
return function(optionName) {
openDropdown();
return element(by.css('.dropdown.open'))
.element(by.linkText(optionName));
}