[cl-selenium-devel] Problems with cl-selenium, Drakma, and nasty JavaScript
Matthew Kennedy
mkennedy at common-lisp.net
Tue Jul 1 07:04:26 UTC 2008
On Tue, Jul 1, 2008 at 12:21 AM, Robin Lee Powell
<rlpowell at digitalkingdom.org> wrote:
>
> The problem is with "element = this.page().findElement(\"~A\"); "
>
> Specifically, the embedded ".
>
> Drakma simply won't accept them:
>
> Parse error:URI "http://localhost:4444/selenium-server/driver/?cmd=getEval&1=element%20%3D%20this.page().findElement(\"id%3Dhome\")%3B%20if(%20element.currentStyle%20)%20%7B%20element.currentStyle.textDecoration%20%7D%20else%20%7B%20this.browserbot.getCurrentWindow().getComputedStyle(%20element,%20null%20).getPropertyValue('text-decoration')%20%7D&sessionId=821656" contains illegal character #\" at position 100.
>
> The obvious solution of replacing them with ' doesn't work, because
> some of my xpaths have ' in them, so that fails entirely. I can't
> just replace the ' in the xpaths with " to make up for *that*,
> because if I do, the " still end up in the Drakma request, and again
> Drakma refuses.
Hi Robin,
It looks like we were doing our own URL encoding in CL-Selenium so
I've changed the code to let Drakma do it (which is the correct place
to do it anyway). Now it should work correctly in every case.
CL-USER> (let* ((selenium:*selenium-driver-url*
"http://localhost:4444/selenium-server/driver")
(selenium:*selenium-session* (selenium:do-get-new-browser-session
"*opera" "http://www.google.com")))
(selenium:do-open "http://www.google.com/webhp?hl=en")
(print (selenium:do-get-eval "\"Hello, \" + \"JavaScript!\""))
(selenium:do-test-complete))
"Hello, JavaScript!"
NIL
I've created a new 0.3 release which includes the fix.
http://common-lisp.net/project/cl-selenium/releases/cl-selenium-0.3.tar.gz
Thanks for noting this problem,
Matt
More information about the cl-selenium-devel
mailing list