elementExplorer角色转义在Protractor 1.8.0和2.0.0上退化了吗?

时间:2015-04-21 07:40:51

标签: javascript selenium-webdriver protractor

我使用的是Node版本0.10.30。 在Protractor 1.6.1上,我能够在ng-show中转义单引号字符以返回值。例如:

element.all(by.css('[ng-if="user"]')).all(by.css('[ng-show="user.name === \'Jhonny\'"]').getText()

然而,在升级到量角器1.8.0和2.0.0之后,字符转义不再起作用了(升级后我回滚到Protractor 1.6.1并再次运行)。然后我尝试另一个代码

element.all(by.css('[ng-if="user"]')).map(function(ele) {return ele;});

上面的代码崩溃了elementExplorer并出现以下错误:

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at Client.addListener (events.js:160:15)
    at CommandRepl.evaluate_ (C:\Users\test\AppData\Roaming\npm\node_modules\protractor\lib\debugger\modes\commandRepl.js:111:15)
    at CommandRepl.stepEval (C:\Users\test\AppData\Roaming\npm\node_modules\protractor\lib\debugger\modes\commandRepl.js:33:8)
    at WdRepl.stepEval_ (C:\Users\test\AppData\Roaming\npm\node_modules\protractor\lib\debugger\clients\explorer.js:48:16)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)
    at ReadStream.onkeypress (readline.js:99:10)

我尝试使用Protractor --elementExplorer中的Node或目录运行elementExplorer,两者都有相同的问题。有其他人经历过这个吗?

1 个答案:

答案 0 :(得分:0)

我在使用Protractor的elementExplorer试图在by.css定位器上转义撇号时遇到了同样的问题。 我的解决方案是使用双反斜杠:

element.all(by.css('[ng-if="user"]')).all(by.css('[ng-show="user.name === \\'Jhonny\\'"]').getText()