Using JavascriptExecutor in the WebDriver Sampler

2,054 views
Skip to first unread message

materia...@gmail.com

unread,
Oct 21, 2014, 4:27:59 PM10/21/14
to jmeter-...@googlegroups.com
In the Java WebDriver you get the JavascriptExecutor by casting like so:
JavascriptExecutor executor = (JavascriptExecutor) driver;\

Then you can do things like:
executor.executeScript("document.getElementById(arguments[0]).click();");

How do you achieve this in the WebDriver sampler?

Cheen-Pin Lim

unread,
Oct 22, 2014, 6:10:25 AM10/22/14
to jmeter-...@googlegroups.com

Hi

You should be able to just call WDS.browser.execute script(...)

Regards
CP

--
You received this message because you are subscribed to the Google Groups "jmeter-plugins" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jmeter-plugin...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

materia...@gmail.com

unread,
Oct 29, 2014, 2:49:40 PM10/29/14
to jmeter-...@googlegroups.com
Yeah, that is what I though as well but doesn't seem to work. I have:

var pkg = JavaImporter(org.openqa.
selenium, org.openqa.selenium.support.ui)

WDS.browser.executeScript("document.getElementById(arguments[0]).click();", "main-nav-accounts-users")

Which gives:
ERROR - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: sun.org.mozilla.javascript.EvaluatorException: Can't find method org.openqa.selenium.remote.RemoteWebDriver.executeScript(string,string). (<Unknown source>#5) in <Unknown source> at line number 5
Message has been deleted

materia...@gmail.com

unread,
Dec 2, 2014, 6:32:48 PM12/2/14
to jmeter-...@googlegroups.com
Any ideas? Using the latest WebDriver plugin set: JMeterPlugins-WebDriver-1.2.0


On Wednesday, October 22, 2014 3:10:25 AM UTC-7, CP Lim wrote:

gli...@gmail.com

unread,
Dec 3, 2014, 2:44:37 PM12/3/14
to jmeter-...@googlegroups.com, materia...@gmail.com
What driver are you trying to use?

materia...@gmail.com

unread,
Dec 5, 2014, 2:26:33 PM12/5/14
to jmeter-...@googlegroups.com, materia...@gmail.com, gli...@gmail.com
Ah, did not think it could be driver specific. Does not work in Chrome but does work in FF.

nivitha....@gmail.com

unread,
Aug 17, 2016, 11:00:48 AM8/17/16
to jmeter-plugins
What's DE solution for this?

nivitha....@gmail.com

unread,
Aug 17, 2016, 11:01:00 AM8/17/16
to jmeter-plugins

Anisha Basnet

unread,
Jul 20, 2021, 3:37:25 AM7/20/21
to jmeter-plugins
I had same issue. You an select Groovy in Script Language.
import org.openqa.selenium.JavascriptExecutor;
WebElement logoButton = WDS.browser.findElement(By.xpath("path"));
WDS.browser.executeScript("arguments[0].click()",logoButton);

Reply all
Reply to author
Forward
0 new messages