Fwd: Beanshell with Jmeter and Selenium
Mark Wilkinson <[email protected]> Mon, 21 Jul 2014 21:56:04 +0100
| Newsgroups | gmane.comp.java.beanshell.user |
|---|---|
| Message-ID | <CANNG-GjcnY48TYdwM39Nq68JwwyrEgRgdTJFkx-Epnqou2NdQQ@mail.gmail.com> |
Doh! Silly typo.. Please ignore.. Just really learning Java ---------- Forwarded message ---------- From: Mark Wilkinson <[email protected]> Date: 21 July 2014 21:48 Subject: Beanshell with Jmeter and Selenium To: beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org 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 [email protected] 07968 398828 -- Mark Wilkinson [email protected] 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