Can protractor test a login that is not angular based |
After placing the issue on github I received the answer I was looking for.
This can be found HERE!
Protractor requires that Angular be present on the page and the way around
this is to use the driver directly. Following the link above should stear
anyone stuck on the same issue in the right direction.
Kudos to JulieMR and the others who helped out with this issue.
|
How to use xsd:any element to return xml as a string |
Just in case someone else has a similar problem to mine, here's the
solution I came up with. It isn't pretty, but it works.
I created a basic Spring MVC web application with a request mapping that
looks exactly like the endpoint from the original service. In the
controller class, parse the input, get the result records from the
database, then manually construct the xml string from the data:
@RequestMapping(value = "/getNewService", method = RequestMethod.POST)
public ModelAndView getNewServicePost() {
StringWriter writer = new StringWriter();
try {
IOUtils.copy(request.getInputStream(), writer, "UTF-8");
} catch (Exception e) {
e.printStackTrace();
}
String theString = writer.toString();
int pNum = XMLUtil.extractNum(theString);
List<Object&
|
Junit Mockito with spring - test case for the Json String return |
hmmm.
You could try
mockMvc.perform(get("/user-byName").sessionAttr("userClientObject",
userClientObject))
.andExpect(status().isOk());
to setup userClientObject in test fixture.
What does "return getUserByName(userClient, firstName, lastName);" exactly
do? If it doesn't involve external dependence, just assert your return in
andExpect(jsonPath()) clause.
I thought it should be @SessionAttribute by the way.
|
string split and return first element in c++ |
Why bother with splitting the whole string and making copies of every token
along the way since you will throw them in the end (because you only need
the first token)?
In your very specific case, just use std::string::find():
std::string s = "one two three";
auto first_token = s.substr(0, s.find(' '));
Note that if no space character is found, your token will be the whole
string.
(and, of course, in C++03 replace auto with the appropriate type name, ie.
std::string)
|
how to remove the lastchild element of dynamically generated DIV and return the html as string |
Generate a DIV dynamically:
$('body').append('<div>');
Access the DIV immediately after generation:
var $divElement = $('body').append('<div>').find('div');
Get the last child:
var $lastChildElement = $divElement.last();
Get the HTML of the last child (more specifically, the innerHTML):
var $lastChildHTML = $lastChildElement.html();
Do it all together then you turn around:
var $lastChildHTML =
$('body').append('<div>').find('div').last().html();
That's what it's all about.
|
How do I change this Spring Test Framework Test to work with a JSON return? |
.andExpect(jsonPath("$.user").value("john"));
with dependency :
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>0.8.1</version>
</dependency>
and one static import like this
import static
org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
adds the static method...
|
JQuery: Find submitted search string in an element. Load into div the element containing that string |
The problem is foundId = $('section:contains('+query+')').attr('id'); will
not return anything since the section elements are not present in the
main.html
Try
$(document).ready(function() {
$('#search-submit').click(function(e){
var query = $("#search-box").val();;
e.preventDefault();
if (query.length > 0) {
$.get('info.html', function(html){
var $html = $(html);
$("#info_display").empty().append($html.find('section:contains('+query+')').first())
}, 'html')
}
else {
alert("Oops, you forgot to enter a search term.");
}
});
});
|
can Regex .test() in JavaScript test the whole string? |
Character classes match single characters. You need to repeat them:
var exp = new RegExp("^([a-z]*)$");
console.log( exp.test('hello') );
console.log( /^([a-z0-9]*)$/.test('abc12') );
Or if you want to require at least one character, use + instead of *.
Also, if you're just using the patterns with test, you can get rid of the
parentheses:
var exp = new RegExp("^[a-z]*$");
console.log( exp.test('hello') );
console.log( /^[a-z0-9]*$/.test('abc12') );
|
Get onClick element to return to the main element? |
You need to correct your syntax errors. Use onclick instead of onClick
(pedantic). Make sure you close your attributes properly, you are missing a
few closing " marks.
updated html
<span onclick="changeNavigation('members')" >MEMBERS</span>
<span onclick="changeNavigation('help')" >HELP</span>`
<div id="members">...</div>
<div id="help" style="display: none;">...</div>
There is also an error with your logic as you are simply replacing the
contents of div#members with itself.
Updated JS without syntax errors, but still with dodgy logic
function changeNavigation(id){
document.getElementById('members').innerHTML=document.getElementById(id).innerHTML;
}
Demo fiddle
http://jsfiddle.net/ADGCV/
As far as your actual question goes, can
|
Decrypt string with Rijndael return "System.SecureString" (as a string) but not the string |
I have implemented rijndael in the past, and here is my version if this is
any help:
private static string Encrypt(string plainText, string passPhrase, string
saltValue, string hashAlgorithm, int passwordIterations, string initVector,
int keySize)
{
// Convert strings into byte arrays.
// Let us assume that strings only contain ASCII codes.
// If strings include Unicode characters, use Unicode, UTF7, or
UTF8
// encoding.
var initVectorBytes = Encoding.ASCII.GetBytes(initVector);
var saltValueBytes = Encoding.ASCII.GetBytes(saltValue);
// Convert our plaintext into a byte array.
// Let us assume that plaintext contains UTF8-encoded
characters.
var plainTextBytes = Encoding.
|
Can changing a function which used to return a const ref to an std::string to return by value break calling code? |
One way this could go wrong is if the calling code does something like:
const char* s = ConvertToString(first).c_str();
And then stores s somewhere and accesses it later, thinking that the
std::string object referenced by the return value of ConvertToString will
never be destroyed.
Of course, that calling code sucks anyway, in that case.
|
Test-Connection Return Value |
the syntax is incorrect
if (Test-Connection -quiet PCNAME)
{
# bla bla bla
}
else
{
# bla bla bla
}
Also, powershell doesnt have an == operator, instead use -eq.
for example if ($foo -eq 0) { ... }
Similary:
-ne not equals
-gt greater than
-gte greater than or equal to
-lt less than
-lte less than or equal to
|
PHP: test == return false when he should not |
Above the test, add this:
var_dump($service->getId());
var_dump($discountsID[$i]);
die();
And see if the outcome matches
Also this seems wrong to me:
foreach ($services as $service) {
$service->getId()
What does $services consist of?
|
Can you return a string from a while loop without using the return command? |
The return statement returns a value from the entire method you're in. But
you're in main, which can't return a value (it's void).
If you want to end the while loop when you have a good value, then use the
break statement to break out of the while loop. Control then passes to the
next statement following the end of the loop.
|
Should I unit test messages that don't return a value? |
In typing the question, I think I've realized the answer: to use the
author's nomenclature, I should test the outgoing "command" messages that
are sent in response to the incoming messages.
For some context, the author later writes, "Many outgoing messages do have
side effects (… an action is taken by an observer) upon which your
application depends. These messages are commands and it is the
respondibility of sending object to prove that they are properly sent."
In my case, my object is a container that sends messages to its children
when its state changes, so that object's test should ensure that those
messages are sent to its children.
|
what test should be put to get nested element |
You have to keep track of whether the parser is currently "inside" an entry
element or not.
For example, you can
add an integer property entryLevel to the class,
set it initially to zero
and update it in didStartElement
and didEndElement:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString
*)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString
*)qualifiedName attributes:(NSDictionary *)attributeDict
{
if ([elementName isEqualToString:@"entry"]) {
self.entryLevel++;
} else if ([elementName isEqualToString:@"title"] &&
self.entryLevel > 0) {
// title inside entry
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if
|
How to test, if an element is in a list? |
No (unless things have changed); just loop through the list.
An alternative is instead / as well have a lookup variable
i.e.
lookup. = 0 /* not all versions of Rexx support
default initialisation like this */
....
addToList:
parse arg item
numberInList = numberInList + 1
list.numberInList = item
lookup.item = 1
return
You can then check if item is in the list by
if lookup.item = 1 then do
......
|
return multiple values in done() of angularjs's e2e test |
You can always loop through your array prevObject and write an expectation
within the loop.
for(var i = 0; i < promise.length; i++) {
expect(promise[i].innerHTML).toMatch(pattern);
}
|
Return a ping test result in Python |
What about something like
edit : try this:
import re
import subprocess
website = "google.com"
try:
ping = subprocess.Popen(["ping", "-n", "-c 5", website],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, error = ping.communicate()
if out:
try:
minimum = int(re.findall(r"Minimum = (d+)", out)[0])
maximum = int(re.findall(r"Maximum = (d+)", out)[0])
average = int(re.findall(r"Average = (d+)", out)[0])
packet = int(re.findall(r"Lost = (d+)", out)[0])
if packet > 1:
packet = 5 / packet * 100
except:
print "no data for one of minimum,maximum,average,packet"
else:
print 'No ping'
except subprocess.CalledProcessError:
print "Couldn't get a ping"
|
QTP Test controled in C# ( return Type Error) |
From http://www.sqaforums.com/showflat.php?Number=438836&page=0:
Unfortunately, Mercury made extensive use of Variant types in their
COM interfaces, and that's something that Interop seems to choke on a
lot.
This, and other non-obvious facts, lead to the type cast problems you
experience.
The key idea is to call the QTP routines via reflection, a la for
exampletestObject.GetType().InvokeMember(), see the thread link for
details.
Also, if you have an active support agreement: there used to be a KB
article, http://support.openview.hp.com/selfsolve/document/KM916723 ...the
ID might lead to a fresher version.
|
Angular E2E Test: Getting "input" from "element" |
Yeah, the E2E input() method is sort of a nuisance as it does a find based
on the ng-model of a particular input.. So for situations like ng-repeat,
it doesn't lend itself to any practical use.
Good news is, you can get the functionality you want just using element().
element('my_element_here').val('Value I want to enter!')
expect(element('my_element_here').val()).toEqual("Value I want to enter!")
Basically, the element() call can be chained with any of these jQuery-esque
methods:
val, text, html, height, innerHeight, outerHeight, width, innerWidth,
outerWidth,
position, scrollLeft, scrollTop, offset.
The E2E Test harness for Angular is... interesting. And in desperate need
of some TLC. But it's actually pretty good at what it does, once you get
over the awkwardness of it! (And assu
|
Controller under unit test return emtpy contentAsString |
Ok, I revisited the Unit Testing section of docs. It seems that the
response.contentAsString can be used only when you render your text
directly. For rendering a view, you can check the item "Testing View
Rendering" of the docs.
Example:
// Test class
class SimpleController {
def home() {
render view: "homePage", model: [title: "Hello World"]
}
…
}
void testIndex() {
controller.home()
assert view == "/simple/homePage"
assert model.title == "Hello World"
}
|
Understanding python's super method, Why D().test() will return 'B->C' and not 'B-->A' |
The short answer is that the method resolution order is roughly "breadth
first". That is, it goes through all the base classes at a given level of
ancestry before going to any of their superclasses. So if D inherits from
B and C, which both inherit from A, the MRO always has B and C before A.
Another way to think about it is that if the order went B->A, then A.test
would be called before C.test, even though C is a subclass of A. You
generally want a subclass implementation to be invoked before the
superclass one (because the subclass one might want to totally override the
superclass and not invoke it at all).
A longer explanation can be found here. You can also find useful
information by googling or searching Stackoverflow for question about
"Python method resolution order" or "Pytho
|
Extract number sets from string, and return as comma seperated values in new string |
You could try this UDF:
Public Function GetNumbers(sMark As String) As String
'regexp declaration
Dim objRegExp As Object
Set objRegExp = CreateObject("vbscript.regexp")
With objRegExp
.Global = True
.Pattern = "(d+)D*"
Dim i As Long
If .Execute(sMark).Count > 1 Then
For i = 0 To .Execute(sMark)(0).submatches.Count
GetNumbers = GetNumbers &
.Execute(sMark)(i).submatches(0) & ","
Next
Else
GetNumbers = .Execute(sMark)(0).submatches(0) & ","
End If
End With
GetNumbers = Left(GetNumbers, Len(GetNumbers) - 1)
End Function
it's tried and tested for examples you provided and hope it will work for
all situations you need.
|
Call a Struts 2 action using ajax, which write a string directly to the response does not return the string |
Instead of using
ServeletActionContext.getResponse().getOutputStream().print("sample
string");
return null;
use this code
PrintWriter out = response.getWriter();
out.write("sample string");
return null;
This should work.
|
Can executeQuery(String sql) function's return value be typecasted to a String Array? |
Answer to your question:
No, is not possible because (from PreparedStatement javadoc)
ResultSet executeQuery() throws SQLException
Executes the SQL query in this PreparedStatement object and returns
the ResultSet object generated by the query.
and you can't change this signature.
Your intention is to return the whole ResultSet in Array<>[] variable
and, for large resultset, this can results in a OutOfMemoryException.
You can think to use Spring JDBC support and JDBCTemplate.queryForList() to
make use of ResultSet mapping easy
EDIT:
About your code best choice is to change query as:
select Col3,MyOption from MyOption where OptionKey in (?,?,?,?) and ID = "
+ _Id";
while(rs.hasNext()) {
String option = rs.getString(2);
String optionValue = rs.getString(1);
String pro
|
How to Return true if String array having mix of Int and String type value converted to int in C# |
Why not use a regular expression? If a string has words and numbers in it,
it must have letters and number characters. I don't entirely understand the
logic in your question, so you may need to adjust the logic here.
using System;
using System.Text.RegularExpressions;
...
string words = "1 2 c 5";
Match numberMatch = Regex.Match(words, @"[0-9]", RegexOptions.IgnoreCase);
Match letterMatch = Regex.Match(words, @"[a-zA-Z]",
RegexOptions.IgnoreCase);
// Here we check the Match instance.
if (numberMatch.Success && letterMatch.Success)
{
// there are letters and numbers
}
|
Nunit loads all test Test data for all the test before the test gets executed |
I think that's by design. NUnit is designed to clean up the environment
before any test, to generate same conditions for any test independent their
execution order.
If Test A would change the XDocument, Test B would be run with that
changes. That might led to indeterminate test results.
If Test B expects changes made from Test A, then your tests are not fully
isolated, that's a bad practice.
If you wan't to change that behaviour, implement a lazy field and load the
test data only on first access. You can increase performance if you know
that you are not changing data in any of your tests, but pay attention.
private static Lazy<IEnumerable> testData = new
Lazy<IEnumerable>(GetExample);
private static IEnumerable GetExample() {
var doc = XDocument.Load("Example.xml");
|
XML test data for large text element? |
Split your type definition into two files with the first ending with:
(caret)xsd:documentation(caret)
and the second beginning with: (caret)/xsd:documentation(caret)
Windows:
type preamblefile 9000charfile postfile > testfile
Linux:
cat preamblefile 9000charfile postfile > testfile
|
Node.js Mocha async test doesn't return from callbacks |
You need to use the asynchronous support in mocha. Try adding done to the
following line:
describe('Should show uploaded files to amazon s3', function (done) {
and you need to add done() below the console.log(res).
Documentation is here:
http://visionmedia.github.io/mocha/#asynchronous-code
|
PHP edit an element of an array and return the array with the edited element |
By using a Reference (note: &) to the element, any changes will affect
the original element:
foreach ($dashboard as &$eDashboard) {
$eDashboard['multimedia_descr'] =
eSetDashboardLabel($eDashboard['multimedia_descr'], getLang());
}
Alternatively, you can capture the key in the loop and reference the array:
foreach ($dashboard as $key => $eDashboard) {
$dashboard[$key]['multimedia_descr'] =
eSetDashboardLabel($eDashboard['multimedia_descr'], getLang());
}
|
Matching A String And Return Preseted Number For The Given String |
Create a lookup array for your data:
$str = '"Harry":"12345","Biswas":"789456","garry":"56894"';
$passwords = array();
foreach( str_getcsv( $str) as $entry) {
list( $name, $pw) = explode( ':', $entry);
$passwords[$name] = $pw;
}
Then, just use their name as the key to find their password:
$fh = "Harry";
echo $passwords[$fh]; // 12345
|
How to test if a string exists in a file and if so, check the remaining lines in the file for another string with bash shell |
if you have awk available, an awk oneliner could do it for you:
awk '/July/{f=1} f&&/foobar/{print "Found foobar after
July!";exit}' file
if no July or no foobar after July, the command prints nothing. of course
you could make an if-else, to let it print "not found" or something.
|
When test is runing to watch in parallel if specific element exist |
Check out EventFiringWebDriver which may help,
http://onlineseleniumtraining.com/how-to-working-with-listeners-in-selenium-webdriver/
|
Loopj (AsyncHttpClient get method) doesnt return response in Android Unit Test |
An asynchronous callback-based Http client for Android built on top of
Apache’s HttpClient libraries. All requests are made outside of your
app’s main UI thread, but any callback logic will be executed on the same
thread as the callback was created using Android’s Handler message
passing.
Check http://loopj.com/android-async-http/ this may help you !
|
String array gets passed to my controller as just a string when there is only one element |
They are sent as string in both case. That's your framework that decodes
the comma separated value list which results of the casting of the array to
a string (try idArray.toString()). It probably does that based on the
Content-Type header of the request.
You can try to use the jsonData option of the request instead of params. If
your framework accepts JSON, the typing of the data will be better
respected.
|
Return the element onmouseover |
Your inline onmouseover is passing the element's id when it should be
passing a reference to the element itself. Try this:
onmouseover="hover(this);"
Also, optionally, you can eliminate the global element variable:
function hover(hoveredElement) {
setInterval(function() {
hoveredElement.style.boxShadow = .... ;
}, 100);
}
Or if you want to keep the other function separate:
function hover(hoveredElement){
setInterval(function(){ changeBack(hoveredElement); }, 100);
}
function changeBack(element){
element.style.boxShadow = .... ;
}
Either way means you can apply the onmouseover="hover(this);" to multiple
elements without them sharing the same global element variable.
|
BUILD FAILED test.xml:7: The markup in the document following the root element must be well-formed |
It's simple: you have no root element. Every XML file requires a root
element, otherwise the markup isn't valid!
|
How can I do a logical test involving the return value of a piped command while taking advantage of short-circuiting? |
I believe the solution is to use the curlies:
$ if ! { [[ a == a ]] && [[ a == c ]]; }; then echo yy; fi
yy
I wonder if there is anything more elegant.
|
jQuery return appended element |
Try .appendTo()
var addNewCategory = function(number) {
var categoryId = (number % 2 == 0 ? 'even' : 'odd'),
category = '<div class="category" id="category_' + categoryId +
'">' + categoryId + '</div>';
return $(category).appendTo(content)
};
|