I want to assign a variable in a function and then use that result to
compare with some data that I retrieved from a csv file. If I want to
compare these two in the function that is reading the element from the
webpage, then the value of the data from the csv would be the last item in
the array. And if I want to use the result of the function outside of the
function and compare it with the data from csv, then the
variable(pageProductName) that contains the result of the function
(textValue) would be undefined, even though I defined the variable outside
the function(globally).
What can I do to use the value of textValue outside of the function?
or
What can I do to have the retrieved data from csv in the right order in the
function?
Here is part of my code that I have problem with:
reader.addListener('data', function(data){
allEntries.push(data);
});
reader.addListener('end', function(end)
{ var i=0;
console.log(allEntries.length);
for(var j=0; j<allEntries.length;j++)
{
ProductURLArray[i]=(BaseURL+allEntries[j]['col3']+".html");
ProductNameArray[i]=allEntries[j]['col2'];
var url = ProductURLArray[i];
var name = ProductNameArray[i];
driver.get(url);
driver.sleep(3000);
driver.findElement(webdriver.By.css('.product-name
h1')).getText().then(function(textValue){
pageProductName=textValue;
});
console.log(pageProductName);
assert.equal(pageProductName, name);
}
});
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/0ef56ddc-400b-4528-9057-3fda9857486f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.