How to enable javascript in HtmlUnit driver?

1,991 views
Skip to first unread message

Xun H.W

unread,
Feb 24, 2013, 12:42:50 AM2/24/13
to clj-we...@googlegroups.com

user=> (set-driver! {:browser :htmlunit} )
#clj_webdriver.driver.Driver{:webdriver #<Title: , URL: about:blank, Browser: htmlunit, Version: , JS Enabled: false, Native Events Enabled: false, Object: org.openqa.selenium.htmlunit.HtmlUnitDriver@5eb9ec47>, :capabilities nil, :cache-spec {:cache nil}, :actions #<Actions org.openqa.selenium.interactions.Actions@4759e7>}

I'm a newbie of clojure

in java it's just
driver.setJavascriptEnabled(true);

but can't found a way in cli-driver , can somebody help me out? 
thanks

Daniel Gregoire

unread,
Feb 24, 2013, 1:55:15 PM2/24/13
to clj-we...@googlegroups.com

I don't think I currently expose top-level functions to make that kind of configuration simple (but I probably should). At the very least you can:

1. Grab the WebDriver instance from within clj-webdriver's Driver record (e.g., (:webdriver your-driver))
2. At that point, you can call setJavascriptEnabled using Clojure's Java interop like (.setJavascriptEnabled (:webdriver your-driver) true)

Though Clojure's data structures are immutable, like the Driver instance my API exposes, any Java objects they may reference, like the WebDriver object from Selenium's API, behave just as you'd expect on the JVM, so the above works.

--
You received this message because you are subscribed to the Google Groups "clj-webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clj-webdrive...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Xun H.W

unread,
Mar 7, 2013, 5:04:30 AM3/7/13
to clj-we...@googlegroups.com
It  works! 
thanks a lot ..
Reply all
Reply to author
Forward
0 new messages