My Variable : 54, 22
What I want : 54,22
I've tried :
Execute Javascript var a = 54, 22;var x = a.split(' ').join('');return x
and
Execute Javascript var a = 54, 22;var x = a.replace(/\s/g, '');return x
and
log ${str.strip()}
But none of them solved my problem. When I execute these code seperately I got that error:
FAIL : WebDriverException: Message: u'unknown error: Runtime.evaluate threw exception: SyntaxError: Unexpected number\n at Object.InjectedScript._evaluateOn (:895:140)\n at Object.InjectedScript._evaluateAndWrap (:828:34)\n at Object.InjectedScript.evaluate (:694:21)\n (Session info: chrome=43.0.2357.124)\n (Driver info: chromedriver=2.12.301325 (962dea43ddd90e7e4224a03fa3c36a421281abb7),platform=Windows NT 6.1 SP1 x86_64)'
How to solve that problem?
My Variable : 54, 22
What I want : 54,22
I've tried :
Execute Javascript var a = 54, 22;var x = a.split(' ').join('');return x
and
Execute Javascript var a = 54, 22;var x = a.replace(/\s/g, '');return x
and
log ${str.strip()}
But none of them solved my problem. When I execute these code seperately I got that error:
FAIL : WebDriverException: Message: u'unknown error: Runtime.evaluate threw exception: SyntaxError: Unexpected number\n at Object.InjectedScript._evaluateOn (:895:140)\n at Object.InjectedScript._evaluateAndWrap (:828:34)\n at Object.InjectedScript.evaluate (:694:21)\n (Session info: chrome=43.0.2357.124)\n (Driver info: chromedriver=2.12.301325 (962dea43ddd90e7e4224a03fa3c36a421281abb7),platform=Windows NT 6.1 SP1 x86_64)'
How to solve that problem?
Share Improve this question edited Jun 18, 2015 at 14:24 buurkeey asked Jun 18, 2015 at 14:22 buurkeeybuurkeey 3692 gold badges5 silver badges20 bronze badges2 Answers
Reset to default 2Using the String Library
The String library has a Replace String keyword that you can use to remove whitespace, without having to resort to running javascript:
*** Settings ***
| Library | String
*** Test Cases ***
| Example of removing whitespace
| | ${value}= | Replace String | 54, 22 | ${space} | ${empty}
| | Should be equal | ${value} | 54,22
Using the Evaluate keyword
You can run arbitrary python code with the Evaluate keyword. For example:
*** Test Cases ***
| Example of removing whitespace
| | ${value}= | Evaluate | "54, 22".replace(" ", "")
| | Should be equal | ${value} | 54,22
You're missing mas in your variable, that's why you're getting syntax error:
var a = '54, 22';
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744786155a4593639.html
评论列表(0条)