ebrehault / resurrectio

CasperJS test recorder Chrome extension
GNU General Public License v2.0
721 stars 106 forks source link

Xpath expression does not escape apostrophes correctly #16

Closed lhorie closed 10 years ago

lhorie commented 10 years ago

See this jsfiddle: http://fiddle.jshell.net/uTatY/1/show/light/

Notice that the script produces invalid xpath:

//==============================================================================
// Casper generated Mon Mar 17 2014 15:44:00 GMT-0400 (Eastern Daylight Time)
//==============================================================================

var x = require('casper').selectXPath;
casper.options.viewportSize = {width: 1366, height: 383};
casper.test.begin('Resurrectio test', function(test) {
   casper.start('http://fiddle.jshell.net/uTatY/1/show/light/');
   casper.waitForSelector(x("//*[normalize-space(text())=\'a\'b\']"),
       function success() {
           test.assertExists(x("//*[normalize-space(text())=\'a\'b\']"));
         },
       function fail() {
           test.assertExists(x("//*[normalize-space(text())=\'a\'b\']"));
   });

   casper.run(function() {test.done();});
});
ebrehault commented 10 years ago

I tried """ or "''", but apprently the only way to write propely is: x("//*[normalize-space(text())=concat('a', \"'\", 'b')]")