You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Bob <b....@gmail.com> on 2015/02/18 12:52:56 UTC

Howto rewrite Java in JavaScript(Rhino engine)

Hi,

I wanted to convert Selenium Java code to JavaScript make it possible to 
run with JMeter but JavaScript code is not working. Converted related to 
this documentation 
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scripting_Java 


|Java Code:

String userAgent = "user_agent_string";
ChromeOptions co = new ChromeOptions();
co.addArguments("--user-agent=" + userAgent);
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(ChromeOptions.CAPABILITY , co);
WebDriver driver = new ChromeDriver(cap);

JavaScript Code:

var ChromeDriver = JavaImporter(org.openqa.selenium.chrome)
ChromeOptions = ChromeDriver.ChromeOptions()

userAgent = new java.lang.String("['start-maximized', '--user-agent=foo']")

var remote = JavaImporter(org.openqa.selenium.remote)
var capabilities = new remote.DesiredCapabilities.chrome()

capabilities.setCapability(ChromeOptions.CAPABILITY, userAgent);

var driver = new ChromeDriver.ChromeDriver(capabilities)

var baseUrl = "http://example.com"

driver.get(baseUrl)

I'm getting error Wrapped org.openqa.selenium.WebDriverException: unknown error: cannot parse capability: chromeOptions.
Any help is appreciated. Thanks in advance.
|



Re: Howto rewrite Java in JavaScript(Rhino engine)

Posted by Felix Schumacher <fe...@internetallee.de>.

Am 18. Februar 2015 12:52:56 MEZ, schrieb Bob <b....@gmail.com>:
>Hi,
>
>I wanted to convert Selenium Java code to JavaScript make it possible
>to 
>run with JMeter but JavaScript code is not working. Converted related
>to 
>this documentation 
>https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scripting_Java
>
>
>
>|Java Code:
>
>String userAgent = "user_agent_string";
>ChromeOptions co = new ChromeOptions();
>co.addArguments("--user-agent=" + userAgent);
>DesiredCapabilities cap = DesiredCapabilities.chrome();
>cap.setCapability(ChromeOptions.CAPABILITY , co);
>WebDriver driver = new ChromeDriver(cap);
>
>JavaScript Code:
>
>var ChromeDriver = JavaImporter(org.openqa.selenium.chrome)
>ChromeOptions = ChromeDriver.ChromeOptions()

Shouldn't you use "new" here, too?

Regards
Felix 
>
>userAgent = new java.lang.String("['start-maximized',
>'--user-agent=foo']")
>
>var remote = JavaImporter(org.openqa.selenium.remote)
>var capabilities = new remote.DesiredCapabilities.chrome()
>
>capabilities.setCapability(ChromeOptions.CAPABILITY, userAgent);
>
>var driver = new ChromeDriver.ChromeDriver(capabilities)
>
>var baseUrl = "http://example.com"
>
>driver.get(baseUrl)
>
>I'm getting error Wrapped org.openqa.selenium.WebDriverException:
>unknown error: cannot parse capability: chromeOptions.
>Any help is appreciated. Thanks in advance.
>|


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: Howto rewrite Java in JavaScript(Rhino engine)

Posted by Bob <b....@gmail.com>.
Well, I found pull request 
https://github.com/Cka3o4Huk/jmeter-plugins/commit/4ee6aa8e8a58b6321a898ccceac1feb0ca9cfb03 
and patched WebDriver plugin. Now it's working. Thanks!


On 19/02/15 23:39, sebb wrote:
> On 19 February 2015 at 16:08, Matthew Pistella <mp...@kingsisle.com> wrote:
>> Jmeter also does have a OS_Process_Sampler http://jmeter.apache.org/usermanual/component_reference.html#OS_Process_Sampler
>>
>> So if you can get your Java Web driver in a self-contained executable jar  you can just call it. I am actually trying to see if I can implement this over the next few weeks if I get some time.
> If it's in a self-contained jar - i.e. it is a Java app with a main()
> entry point - then it can also be called from BeanShell.
> That should be reasonably efficient - probably cheaper than launching
> a new OS process - though I've not measured this.
>
> Other JSR223 samplers may also be able to invoke Java code.
>
>> Beanshell is a great option for  tiny manipulations to variables and such. However, it is not great if you are going to handle large data structures and need to pass them between thread groups(this can still be done with the use of Jmeter Properties but things can start to get real messy real quick).
> Any test elements that manipulate large data structures need to be
> careful about memory usage.
>
> But I agree that BeanShell is mainly intended for proof of concept
> test elements and snippets of code.
>
> If performance starts to become an issue, then the open design of
> JMeter allows users to add their own test elements very easily.
>
>> Regards,
>>
>> Matthew Pistella
>> QA, Automation Engineer I
>> KingsIsle Entertainment, Inc.
>>
>> -----Original Message-----
>> From: David Luu [mailto:mangaroo@gmail.com]
>> Sent: Thursday, February 19, 2015 12:07 AM
>> To: JMeter Users List
>> Subject: Re: Howto rewrite Java in JavaScript(Rhino engine)
>>
>> I see, then yes, Beanshell would be the better option. But be warned that Beanshell isn't exactly 100% Java syntax, therefore, depending on the exact Java code you need to run on Beanshell, some of it may have to be tweaked to run on Beanshell as I've encountered before, regarding sendKeys and executeScript. I don't know what other WebDriver Java API methods are affected.
>>
>> https://groups.google.com/forum/#!topic/webdriver/vlaBV7OO5Hs
>> http://grokbase.com/t/gg/webdriver/127kf2h8n4/javascript-executor-issues-in-java-beanshell
>>
>> On Wed, Feb 18, 2015 at 9:05 PM, Bob <b....@gmail.com> wrote:
>>
>>> Well, the problem is I wanted to use ChromeOptions which is not
>>> implemented in ChromeDriverConfig, so decided to import Java classes.
>>> Created StackOverflow question with code examples:
>>> http://stackoverflow.com/questions/28581029/jmeter-
>>> webdriver-plugin-mobile-emulation
>>>
>>> I think maybe it's better to use pure Java code with Beanshell sampler
>>> as sebb mentioned.
>>> On 19/02/15 09:52, David Luu wrote:
>>>
>>>> Unless the WebDriver sampler API/design has changed in newer versions
>>>> and you're using an older version, perhaps you are not using it the
>>>> correct way, or rather at least not the normal way? Have you tried
>>>> using it the normal way? As suggested by the tutorial/documentation:
>>>>
>>>> http://jmeter-plugins.org/wiki/WebDriverTutorial/
>>>> http://jmeter-plugins.org/wiki/WebDriverSampler/
>>>> http://jmeter-plugins.org/wiki/ChromeDriverConfig/
>>>>
>>>> It seems for the normal way, you configure ChromeDriverConfig element
>>>> graphically/manually in JMeter, not from code (although there's no
>>>> reason not to do it from code). Then you use the WebDriverSampler's
>>>> object to work with WebDriver, not instantiate your own driver
>>>> instance. So with the Chrome config defined manually in JMeter GUI,
>>>> all your code needs to do are things like:
>>>>
>>>> var pkg = JavaImporter(org.openqa.selenium) var what =
>>>> WDS.browser.findElement(pkg.By.id('what'))
>>>> what.sendKeys(['tyres'])
>>>>
>>>> If it fails the normal way, it's a JMeter WebDriver plugin issue. If
>>>> it just fails in your original code, then it's has to do with how you
>>>> are calling WebDriver classes, but why go that route if you can take
>>>> the normal route?
>>>>
>>>> On Wed, Feb 18, 2015 at 9:52 AM, Bob <b....@gmail.com> wrote:
>>>>
>>>>   I wanted to use with WebDriver sampler, it supports only JavaScript.
>>>>> On 18/02/15 18:17, sebb wrote:
>>>>>
>>>>>   On 18 February 2015 at 11:52, Bob <b....@gmail.com> wrote:
>>>>>>   Hi,
>>>>>>> I wanted to convert Selenium Java code to JavaScript make it
>>>>>>> possible to run with JMeter
>>>>>>>
>>>>>>>   Why convert?
>>>>>> The BeanShell sampler runs most Java code.
>>>>>>
>>>>>> -------------------------------------------------------------------
>>>>>> -- To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>>>>>> For additional commands, e-mail: user-help@jmeter.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>> -------------------------------------------------------------------
>>>>>> --
>>>>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>>>>> For additional commands, e-mail: user-help@jmeter.apache.org
>>>>>
>>>>>
>>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>>> For additional commands, e-mail: user-help@jmeter.apache.org
>>>
>>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: Howto rewrite Java in JavaScript(Rhino engine)

Posted by sebb <se...@gmail.com>.
On 19 February 2015 at 16:08, Matthew Pistella <mp...@kingsisle.com> wrote:
> Jmeter also does have a OS_Process_Sampler http://jmeter.apache.org/usermanual/component_reference.html#OS_Process_Sampler
>
> So if you can get your Java Web driver in a self-contained executable jar  you can just call it. I am actually trying to see if I can implement this over the next few weeks if I get some time.

If it's in a self-contained jar - i.e. it is a Java app with a main()
entry point - then it can also be called from BeanShell.
That should be reasonably efficient - probably cheaper than launching
a new OS process - though I've not measured this.

Other JSR223 samplers may also be able to invoke Java code.

> Beanshell is a great option for  tiny manipulations to variables and such. However, it is not great if you are going to handle large data structures and need to pass them between thread groups(this can still be done with the use of Jmeter Properties but things can start to get real messy real quick).

Any test elements that manipulate large data structures need to be
careful about memory usage.

But I agree that BeanShell is mainly intended for proof of concept
test elements and snippets of code.

If performance starts to become an issue, then the open design of
JMeter allows users to add their own test elements very easily.

> Regards,
>
> Matthew Pistella
> QA, Automation Engineer I
> KingsIsle Entertainment, Inc.
>
> -----Original Message-----
> From: David Luu [mailto:mangaroo@gmail.com]
> Sent: Thursday, February 19, 2015 12:07 AM
> To: JMeter Users List
> Subject: Re: Howto rewrite Java in JavaScript(Rhino engine)
>
> I see, then yes, Beanshell would be the better option. But be warned that Beanshell isn't exactly 100% Java syntax, therefore, depending on the exact Java code you need to run on Beanshell, some of it may have to be tweaked to run on Beanshell as I've encountered before, regarding sendKeys and executeScript. I don't know what other WebDriver Java API methods are affected.
>
> https://groups.google.com/forum/#!topic/webdriver/vlaBV7OO5Hs
> http://grokbase.com/t/gg/webdriver/127kf2h8n4/javascript-executor-issues-in-java-beanshell
>
> On Wed, Feb 18, 2015 at 9:05 PM, Bob <b....@gmail.com> wrote:
>
>> Well, the problem is I wanted to use ChromeOptions which is not
>> implemented in ChromeDriverConfig, so decided to import Java classes.
>> Created StackOverflow question with code examples:
>> http://stackoverflow.com/questions/28581029/jmeter-
>> webdriver-plugin-mobile-emulation
>>
>> I think maybe it's better to use pure Java code with Beanshell sampler
>> as sebb mentioned.
>> On 19/02/15 09:52, David Luu wrote:
>>
>>> Unless the WebDriver sampler API/design has changed in newer versions
>>> and you're using an older version, perhaps you are not using it the
>>> correct way, or rather at least not the normal way? Have you tried
>>> using it the normal way? As suggested by the tutorial/documentation:
>>>
>>> http://jmeter-plugins.org/wiki/WebDriverTutorial/
>>> http://jmeter-plugins.org/wiki/WebDriverSampler/
>>> http://jmeter-plugins.org/wiki/ChromeDriverConfig/
>>>
>>> It seems for the normal way, you configure ChromeDriverConfig element
>>> graphically/manually in JMeter, not from code (although there's no
>>> reason not to do it from code). Then you use the WebDriverSampler's
>>> object to work with WebDriver, not instantiate your own driver
>>> instance. So with the Chrome config defined manually in JMeter GUI,
>>> all your code needs to do are things like:
>>>
>>> var pkg = JavaImporter(org.openqa.selenium) var what =
>>> WDS.browser.findElement(pkg.By.id('what'))
>>> what.sendKeys(['tyres'])
>>>
>>> If it fails the normal way, it's a JMeter WebDriver plugin issue. If
>>> it just fails in your original code, then it's has to do with how you
>>> are calling WebDriver classes, but why go that route if you can take
>>> the normal route?
>>>
>>> On Wed, Feb 18, 2015 at 9:52 AM, Bob <b....@gmail.com> wrote:
>>>
>>>  I wanted to use with WebDriver sampler, it supports only JavaScript.
>>>>
>>>> On 18/02/15 18:17, sebb wrote:
>>>>
>>>>  On 18 February 2015 at 11:52, Bob <b....@gmail.com> wrote:
>>>>>
>>>>>  Hi,
>>>>>>
>>>>>> I wanted to convert Selenium Java code to JavaScript make it
>>>>>> possible to run with JMeter
>>>>>>
>>>>>>  Why convert?
>>>>>
>>>>> The BeanShell sampler runs most Java code.
>>>>>
>>>>> -------------------------------------------------------------------
>>>>> -- To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>>>>> For additional commands, e-mail: user-help@jmeter.apache.org
>>>>>
>>>>>
>>>>>
>>>>> -------------------------------------------------------------------
>>>>> --
>>>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>>>> For additional commands, e-mail: user-help@jmeter.apache.org
>>>>
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>> For additional commands, e-mail: user-help@jmeter.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


RE: Howto rewrite Java in JavaScript(Rhino engine)

Posted by Matthew Pistella <mp...@kingsisle.com>.
Jmeter also does have a OS_Process_Sampler http://jmeter.apache.org/usermanual/component_reference.html#OS_Process_Sampler

So if you can get your Java Web driver in a self-contained executable jar  you can just call it. I am actually trying to see if I can implement this over the next few weeks if I get some time. 

Beanshell is a great option for  tiny manipulations to variables and such. However, it is not great if you are going to handle large data structures and need to pass them between thread groups(this can still be done with the use of Jmeter Properties but things can start to get real messy real quick). 
 
Regards,

Matthew Pistella
QA, Automation Engineer I
KingsIsle Entertainment, Inc.

-----Original Message-----
From: David Luu [mailto:mangaroo@gmail.com] 
Sent: Thursday, February 19, 2015 12:07 AM
To: JMeter Users List
Subject: Re: Howto rewrite Java in JavaScript(Rhino engine)

I see, then yes, Beanshell would be the better option. But be warned that Beanshell isn't exactly 100% Java syntax, therefore, depending on the exact Java code you need to run on Beanshell, some of it may have to be tweaked to run on Beanshell as I've encountered before, regarding sendKeys and executeScript. I don't know what other WebDriver Java API methods are affected.

https://groups.google.com/forum/#!topic/webdriver/vlaBV7OO5Hs
http://grokbase.com/t/gg/webdriver/127kf2h8n4/javascript-executor-issues-in-java-beanshell

On Wed, Feb 18, 2015 at 9:05 PM, Bob <b....@gmail.com> wrote:

> Well, the problem is I wanted to use ChromeOptions which is not 
> implemented in ChromeDriverConfig, so decided to import Java classes.
> Created StackOverflow question with code examples:
> http://stackoverflow.com/questions/28581029/jmeter-
> webdriver-plugin-mobile-emulation
>
> I think maybe it's better to use pure Java code with Beanshell sampler 
> as sebb mentioned.
> On 19/02/15 09:52, David Luu wrote:
>
>> Unless the WebDriver sampler API/design has changed in newer versions 
>> and you're using an older version, perhaps you are not using it the 
>> correct way, or rather at least not the normal way? Have you tried 
>> using it the normal way? As suggested by the tutorial/documentation:
>>
>> http://jmeter-plugins.org/wiki/WebDriverTutorial/
>> http://jmeter-plugins.org/wiki/WebDriverSampler/
>> http://jmeter-plugins.org/wiki/ChromeDriverConfig/
>>
>> It seems for the normal way, you configure ChromeDriverConfig element 
>> graphically/manually in JMeter, not from code (although there's no 
>> reason not to do it from code). Then you use the WebDriverSampler's 
>> object to work with WebDriver, not instantiate your own driver 
>> instance. So with the Chrome config defined manually in JMeter GUI, 
>> all your code needs to do are things like:
>>
>> var pkg = JavaImporter(org.openqa.selenium) var what = 
>> WDS.browser.findElement(pkg.By.id('what'))
>> what.sendKeys(['tyres'])
>>
>> If it fails the normal way, it's a JMeter WebDriver plugin issue. If 
>> it just fails in your original code, then it's has to do with how you 
>> are calling WebDriver classes, but why go that route if you can take 
>> the normal route?
>>
>> On Wed, Feb 18, 2015 at 9:52 AM, Bob <b....@gmail.com> wrote:
>>
>>  I wanted to use with WebDriver sampler, it supports only JavaScript.
>>>
>>> On 18/02/15 18:17, sebb wrote:
>>>
>>>  On 18 February 2015 at 11:52, Bob <b....@gmail.com> wrote:
>>>>
>>>>  Hi,
>>>>>
>>>>> I wanted to convert Selenium Java code to JavaScript make it 
>>>>> possible to run with JMeter
>>>>>
>>>>>  Why convert?
>>>>
>>>> The BeanShell sampler runs most Java code.
>>>>
>>>> -------------------------------------------------------------------
>>>> -- To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>>>> For additional commands, e-mail: user-help@jmeter.apache.org
>>>>
>>>>
>>>>  
>>>> -------------------------------------------------------------------
>>>> --
>>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>>> For additional commands, e-mail: user-help@jmeter.apache.org
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>

Re: Howto rewrite Java in JavaScript(Rhino engine)

Posted by David Luu <ma...@gmail.com>.
I see, then yes, Beanshell would be the better option. But be warned that
Beanshell isn't exactly 100% Java syntax, therefore, depending on the exact
Java code you need to run on Beanshell, some of it may have to be tweaked
to run on Beanshell as I've encountered before, regarding sendKeys and
executeScript. I don't know what other WebDriver Java API methods are
affected.

https://groups.google.com/forum/#!topic/webdriver/vlaBV7OO5Hs
http://grokbase.com/t/gg/webdriver/127kf2h8n4/javascript-executor-issues-in-java-beanshell

On Wed, Feb 18, 2015 at 9:05 PM, Bob <b....@gmail.com> wrote:

> Well, the problem is I wanted to use ChromeOptions which is not
> implemented in ChromeDriverConfig, so decided to import Java classes.
> Created StackOverflow question with code examples:
> http://stackoverflow.com/questions/28581029/jmeter-
> webdriver-plugin-mobile-emulation
>
> I think maybe it's better to use pure Java code with Beanshell sampler as
> sebb mentioned.
> On 19/02/15 09:52, David Luu wrote:
>
>> Unless the WebDriver sampler API/design has changed in newer versions and
>> you're using an older version, perhaps you are not using it the correct
>> way, or rather at least not the normal way? Have you tried using it the
>> normal way? As suggested by the tutorial/documentation:
>>
>> http://jmeter-plugins.org/wiki/WebDriverTutorial/
>> http://jmeter-plugins.org/wiki/WebDriverSampler/
>> http://jmeter-plugins.org/wiki/ChromeDriverConfig/
>>
>> It seems for the normal way, you configure ChromeDriverConfig element
>> graphically/manually in JMeter, not from code (although there's no reason
>> not to do it from code). Then you use the WebDriverSampler's object to
>> work
>> with WebDriver, not instantiate your own driver instance. So with the
>> Chrome config defined manually in JMeter GUI, all your code needs to do
>> are
>> things like:
>>
>> var pkg = JavaImporter(org.openqa.selenium)
>> var what = WDS.browser.findElement(pkg.By.id('what'))
>> what.sendKeys(['tyres'])
>>
>> If it fails the normal way, it's a JMeter WebDriver plugin issue. If it
>> just fails in your original code, then it's has to do with how you are
>> calling WebDriver classes, but why go that route if you can take the
>> normal
>> route?
>>
>> On Wed, Feb 18, 2015 at 9:52 AM, Bob <b....@gmail.com> wrote:
>>
>>  I wanted to use with WebDriver sampler, it supports only JavaScript.
>>>
>>> On 18/02/15 18:17, sebb wrote:
>>>
>>>  On 18 February 2015 at 11:52, Bob <b....@gmail.com> wrote:
>>>>
>>>>  Hi,
>>>>>
>>>>> I wanted to convert Selenium Java code to JavaScript make it possible
>>>>> to
>>>>> run
>>>>> with JMeter
>>>>>
>>>>>  Why convert?
>>>>
>>>> The BeanShell sampler runs most Java code.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>>>> For additional commands, e-mail: user-help@jmeter.apache.org
>>>>
>>>>
>>>>  ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>>> For additional commands, e-mail: user-help@jmeter.apache.org
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>

Re: Howto rewrite Java in JavaScript(Rhino engine)

Posted by Bob <b....@gmail.com>.
Well, the problem is I wanted to use ChromeOptions which is not 
implemented in ChromeDriverConfig, so decided to import Java classes. 
Created StackOverflow question with code examples:
http://stackoverflow.com/questions/28581029/jmeter-webdriver-plugin-mobile-emulation

I think maybe it's better to use pure Java code with Beanshell sampler 
as sebb mentioned.
On 19/02/15 09:52, David Luu wrote:
> Unless the WebDriver sampler API/design has changed in newer versions and
> you're using an older version, perhaps you are not using it the correct
> way, or rather at least not the normal way? Have you tried using it the
> normal way? As suggested by the tutorial/documentation:
>
> http://jmeter-plugins.org/wiki/WebDriverTutorial/
> http://jmeter-plugins.org/wiki/WebDriverSampler/
> http://jmeter-plugins.org/wiki/ChromeDriverConfig/
>
> It seems for the normal way, you configure ChromeDriverConfig element
> graphically/manually in JMeter, not from code (although there's no reason
> not to do it from code). Then you use the WebDriverSampler's object to work
> with WebDriver, not instantiate your own driver instance. So with the
> Chrome config defined manually in JMeter GUI, all your code needs to do are
> things like:
>
> var pkg = JavaImporter(org.openqa.selenium)
> var what = WDS.browser.findElement(pkg.By.id('what'))
> what.sendKeys(['tyres'])
>
> If it fails the normal way, it's a JMeter WebDriver plugin issue. If it
> just fails in your original code, then it's has to do with how you are
> calling WebDriver classes, but why go that route if you can take the normal
> route?
>
> On Wed, Feb 18, 2015 at 9:52 AM, Bob <b....@gmail.com> wrote:
>
>> I wanted to use with WebDriver sampler, it supports only JavaScript.
>>
>> On 18/02/15 18:17, sebb wrote:
>>
>>> On 18 February 2015 at 11:52, Bob <b....@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I wanted to convert Selenium Java code to JavaScript make it possible to
>>>> run
>>>> with JMeter
>>>>
>>> Why convert?
>>>
>>> The BeanShell sampler runs most Java code.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>>> For additional commands, e-mail: user-help@jmeter.apache.org
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>> For additional commands, e-mail: user-help@jmeter.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: Howto rewrite Java in JavaScript(Rhino engine)

Posted by David Luu <ma...@gmail.com>.
Unless the WebDriver sampler API/design has changed in newer versions and
you're using an older version, perhaps you are not using it the correct
way, or rather at least not the normal way? Have you tried using it the
normal way? As suggested by the tutorial/documentation:

http://jmeter-plugins.org/wiki/WebDriverTutorial/
http://jmeter-plugins.org/wiki/WebDriverSampler/
http://jmeter-plugins.org/wiki/ChromeDriverConfig/

It seems for the normal way, you configure ChromeDriverConfig element
graphically/manually in JMeter, not from code (although there's no reason
not to do it from code). Then you use the WebDriverSampler's object to work
with WebDriver, not instantiate your own driver instance. So with the
Chrome config defined manually in JMeter GUI, all your code needs to do are
things like:

var pkg = JavaImporter(org.openqa.selenium)
var what = WDS.browser.findElement(pkg.By.id('what'))
what.sendKeys(['tyres'])

If it fails the normal way, it's a JMeter WebDriver plugin issue. If it
just fails in your original code, then it's has to do with how you are
calling WebDriver classes, but why go that route if you can take the normal
route?

On Wed, Feb 18, 2015 at 9:52 AM, Bob <b....@gmail.com> wrote:

> I wanted to use with WebDriver sampler, it supports only JavaScript.
>
> On 18/02/15 18:17, sebb wrote:
>
>> On 18 February 2015 at 11:52, Bob <b....@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I wanted to convert Selenium Java code to JavaScript make it possible to
>>> run
>>> with JMeter
>>>
>> Why convert?
>>
>> The BeanShell sampler runs most Java code.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>> For additional commands, e-mail: user-help@jmeter.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>

Re: Howto rewrite Java in JavaScript(Rhino engine)

Posted by Bob <b....@gmail.com>.
I wanted to use with WebDriver sampler, it supports only JavaScript.

On 18/02/15 18:17, sebb wrote:
> On 18 February 2015 at 11:52, Bob <b....@gmail.com> wrote:
>> Hi,
>>
>> I wanted to convert Selenium Java code to JavaScript make it possible to run
>> with JMeter
> Why convert?
>
> The BeanShell sampler runs most Java code.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: Howto rewrite Java in JavaScript(Rhino engine)

Posted by sebb <se...@gmail.com>.
On 18 February 2015 at 11:52, Bob <b....@gmail.com> wrote:
> Hi,
>
> I wanted to convert Selenium Java code to JavaScript make it possible to run
> with JMeter

Why convert?

The BeanShell sampler runs most Java code.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org