Protractor:How to remove extra space from string just like we use in java getText.trim()

977 views
Skip to first unread message

Sujata Dwivedi

unread,
Feb 17, 2015, 7:48:20 AM2/17/15
to ang...@googlegroups.com
Hi All,

How to remove extra space from string just like we use in java getText.trim() in Protractor

Thanks,
Sujata

Sander Elias

unread,
Feb 17, 2015, 9:46:28 AM2/17/15
to ang...@googlegroups.com
Use trim().

"  blah  ".trim() ==> "blah"

Regards
Sander

Sujata Dwivedi

unread,
Feb 17, 2015, 11:47:04 PM2/17/15
to ang...@googlegroups.com
Thank you for your answer i tried but i got error-
Object [object Object] has no method 'trim'
I used like this:

var columnvalue=rows.get(9).getText();
var columnvalue1=columnvalue.trim();

I am using protractor for testing angular js page.


Subbarao G

unread,
Feb 18, 2015, 1:43:46 AM2/18/15
to ang...@googlegroups.com
The reason you get that error is your columnvalue is not the string

 rows.get(9).getText().then(function(text) {
  console.log(text);
var columnvalue1=text.trim();
console.log(columnvalue1);
 });

Should work.

Sujata Dwivedi

unread,
Feb 18, 2015, 2:32:52 AM2/18/15
to ang...@googlegroups.com
Thank you,now its working fine...
Reply all
Reply to author
Forward
0 new messages