Beanshell with Jmeter and Selenium

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Beanshell with Jmeter and Selenium

Mark Wilkinson-2
Hi folks

Trying to use Beanshell in conjunction with Jmeter. Jmeter exposes a
JmeterVariables instance to Beanshell in a variable named vars. vars allows
you to add arbitrary objects via the putObject method. putObject takes two
arguments.. a String that gives the name/key of the object, and an
arbitrary Object to be added.. i.e. vars.putObject(String string, Object
object). When I call this from my code to add a ChromeDriverService Object,
the method locator tries to find a method that matches *exactly* the
classes for each of the parameters to the method call and complains that I
can't add an object of the class
org.openqa.selenium.chrome.ChromeDriverService..  the ChromeDriverService
object I'm adding is an indirect subclass of Object so I would expect it to
work but it doesn't. Seems like beanshell wants to match in a very precise
way without looking at the superclass(es) of the object I'm trying to add
which naturally resolve to Object if you follow the subclassing path
upwards as you'd expect.. I've tried casting explicitly to (Object) but
that doesn't work.. See code snippet below..

import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public void CreateSeleniumChromeDriver(String ServiceName, String
DriverName) {
     ChromeDriverService.Builder builder;
     ChromeDriverService service;
  WebDriver driver;
     String PathToChromeExecutable="C:\\Users\\Mark  HP
Laptop\\Downloads\\JMeter-TP-Build-1.0\\bin\\chromedriver.exe";

  builder = new ChromeDriverService.Builder();
  builder.usingDriverExecutable(new File(PathToChromeExecutable));
  builder.usingAnyFreePort();
     service = builder.build();

     service.start();

     driver = new RemoteWebDriver(service.getUrl(),
         DesiredCapabilities.chrome());

     vars.putOjbect(ServiceName,service); // fails on this method call
     vars.putObject(DriverName,driver);
}

Thoughts?

--
Mark Wilkinson
[hidden email] 07968 398828
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Fwd: Beanshell with Jmeter and Selenium

Mark Wilkinson-2
Doh! Silly typo.. Please ignore.. Just really learning Java

---------- Forwarded message ----------
From: Mark Wilkinson <[hidden email]>
Date: 21 July 2014 21:48
Subject: Beanshell with Jmeter and Selenium
To: [hidden email]


Hi folks

Trying to use Beanshell in conjunction with Jmeter. Jmeter exposes a
JmeterVariables instance to Beanshell in a variable named vars. vars allows
you to add arbitrary objects via the putObject method. putObject takes two
arguments.. a String that gives the name/key of the object, and an
arbitrary Object to be added.. i.e. vars.putObject(String string, Object
object). When I call this from my code to add a ChromeDriverService Object,
the method locator tries to find a method that matches *exactly* the
classes for each of the parameters to the method call and complains that I
can't add an object of the class
org.openqa.selenium.chrome.ChromeDriverService..  the ChromeDriverService
object I'm adding is an indirect subclass of Object so I would expect it to
work but it doesn't. Seems like beanshell wants to match in a very precise
way without looking at the superclass(es) of the object I'm trying to add
which naturally resolve to Object if you follow the subclassing path
upwards as you'd expect.. I've tried casting explicitly to (Object) but
that doesn't work.. See code snippet below..

import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public void CreateSeleniumChromeDriver(String ServiceName, String
DriverName) {
     ChromeDriverService.Builder builder;
     ChromeDriverService service;
  WebDriver driver;
     String PathToChromeExecutable="C:\\Users\\Mark  HP
Laptop\\Downloads\\JMeter-TP-Build-1.0\\bin\\chromedriver.exe";

  builder = new ChromeDriverService.Builder();
  builder.usingDriverExecutable(new File(PathToChromeExecutable));
  builder.usingAnyFreePort();
     service = builder.build();

     service.start();

     driver = new RemoteWebDriver(service.getUrl(),
         DesiredCapabilities.chrome());

     vars.putOjbect(ServiceName,service); // fails on this method call
     vars.putObject(DriverName,driver);
}

Thoughts?

--
Mark Wilkinson
[hidden email] 07968 398828



--
Mark Wilkinson
[hidden email] 07968 398828
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Loading...