Method executeScript( java.lang.String, org.openqa.selenium.remote.RemoteWebElement ) - jmeter

I am writing code for Jmeter webdriver Sampler when I use Javascript executor I am getting error as
Sourced file: inline evaluation of:
import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.*;
import o . . . '' :
I am getting the error:
Error in method invocation: Method executeScript( java.lang.String, org.openqa.selenium.remote.RemoteWebElement ) not found in class'org.openqa.selenium.chrome.ChromeDriver' :
I am getting error at line:
WebElement checkItemOnly=WDS.browser.findElement(By.xpath("//td[span[text()='Create Item Only']]/following-sibling::td//input[#type='checkbox']"));
JavascriptExecutor jse2 = (JavascriptExecutor)WDS.browser;
jse2.executeScript("arguments[0].scrollIntoView()", checkItemOnly);
checkItemOnly.click();
I am using Java as a language and chrome browser. I am stucked due to this error.

There is no such a language as java in the WebDriver Sampler, what you think being Java is actually Beanshell
There is no need to cast WDS.browser to JavascriptExecutor
So given you:
Change the language to groovy
Change these lines:
JavascriptExecutor jse2 = (JavascriptExecutor)WDS.browser;
jse2.executeScript("arguments[0].scrollIntoView()", checkItemOnly);
to this one:
WDS.browser.executeScript("arguments[0].scrollIntoView()", checkItemOnly)
your code should start working more or less as you expect it to work
More information:
JMeter Best Practices - Beanshell scripting
Apache Groovy - Why and How You Should Use It

Related

Attribute error while executing jmeter script with robotframework

I am trying to execute jmeter with Robot Framework but getting attribute error when I tried to pass extra parameter. I tried below solution but it doesn't work.
How to pass values to the user defined variable in jmeter's jmx file via robot framework
Error:
robot TestCases/TC2_jmeter.robot
==============================================================================
TC2 jmeter
==============================================================================
Get_weather_info | FAIL |
AttributeError: module 'string' has no attribute 'split'
------------------------------------------------------------------------------
TC2 jmeter | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Sounds like usage of a deprecated string function
If you're using this library then it supposed to work with Python 2.7, I think you should be able to still get it, or alternatively identify and re-write the problematic piece of the library, it's open source in any case.
In general you should not need any extra libraries, it's quite possible to kick off a JMeter test in non-GUI mode or generate a HTML Reporting Dashboard using subprocess module

How do I resolve oracle jdbc proxy class error in Evosuite generated tests?

I've written a JDBC driver and I'm trying to use Evosuite to generate the tests for it.
I'm using the following command line:
mvn -Dcores=5 -DmemoryInMB=5000 -Dmock_if_no_generator=false -DextraArgs=' -Dmock_if_no_generator=false -Dskip_covered=true Duse_separate_classloader=false -Dmax_recursion=50 -Dlocal_search_restore_coverage=true -Duse_existing_coverage=true -Dsandbox=false -Dsort_calls=true 'evosuite:generate
The code that is generated is below:
oracle.1jdbc.1replay.1driver.1NonTxnReplayableBase.2java.1sql.1DatabaseMetaData...Proxy oracle_1jdbc_1replay_1driver_1NonTxnReplayableBase_2java_1sql_1DatabaseMetaData___Proxy0 = new oracle.1jdbc.1replay.1driver.1NonTxnReplayableBase.2java.1sql.1DatabaseMetaData...Proxy((DatabaseMetaData) null, "k-{`1N&KKC", proxyFactory0, hashtable0);
and I'm getting the following error on the first line:
:[4618,7] not a statement
:[4618,13] ';' expected
(getting this error three times on the same line)
I was hoping to turn off the mocking but it didn't work it seems.
I'll try to see if I can provide more details later, but any initial thoughts from anyone?
Thanks!

Handling Waitfor Popup & select window using Ruby Webdriver

When I tried exporting Selenium IDE capture into Ruby - webdriver, I get the following for waitforpopup and select window scenarios.
ERROR: Caught exception [ERROR: Unsupported command [waitForPopUp | | 30000]]
# ERROR: Caught exception [ERROR: Unsupported command [selectWindow | title=TestQA - Des2013 | ]]
How do I handle similar situation using ruby webdriver, as we used to do in selenium RC.
selenium.waitforpopup(windowname, 3000)
selenium.selectWindow(windowname)
Some commands cannot be exported to ruby/rspec scripts.
Is that an overlay? If yes, you can just interact with it with no problem.
Is that another frame? you can use the code below
driver.switch_to.frame "some-frame" # name or id
driver.switch_to.frame driver.find_element(:id, 'some-frame') # frame element
Is that another tab/window? you can use the code below
driver.switch_to.window("<window_handle>")

Reading a external XML file using __XPath(${__P(fileName)}

I have a situation where in I am trying to read a node value of an external XML. I am using BeanShell sampler to read the fileName (passed via command line) and using setProperty method setting the value of the parsed node:
${__setProperty(variable_name,${__XPath(${__P(fileName)},/Allocations/item/#name)})}
Though the above method retrieves the value of the node I intended to receive, there is a error thrown:
2013/03/19 19:32:59 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: `` D:\myProject\Jmeter Tests\allocate.xml ;'' Token Parsing Error: Lexical error at line 2, column 3. Encountered: "\" (92), after : ""
My xml file looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<Allocations>
<item name="CAR" />
</Allocations>
Kindly advice if I am doing some error while reading.
Very strange because looks you are doing everything correct.
I've reproduced your scenario step-by-step but works fine for me.
Try to use e.g. Debug Sampler / Debug PostProcessor to monitor your jmeter properties and ensure that fileName normally set from command-line and doesn't contain any extra symbols.

Subreport Data Source Expression for XML document

I'm trying to get a subreport working for a report using an XML document as a data source.
When I'm sorting main report data, subreport won't have to requery the XML document. Its expecting a JRSortableDataSource, not a JRXmlDataSource.
What am I doing wrong?
I used following datasource expression:
$P{REPORT_DATA_SOURCE}).subDataSource("/person/phone")
The stack trace:
Error filling print... Error evaluating expression : Source text : $P{REPORT_DATA_SOURCE}.subDataSource("/person/phone")
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : $P{REPORT_DATA_SOURCE}.subDataSource("/person/phone")
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:203)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559)
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:966)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:384)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:286)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:259)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:459)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2044)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:778)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:288)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:151)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:909)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:126)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:464)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:300)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:757)
at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:1003)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997) Caused by: groovy.lang.MissingMethodException:
No signature of method: net.sf.jasperreports.engine.fill.SortedDataSource.subDataSource()
is applicable for argument types: (java.lang.String) values: [/person/phone]
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)
at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at TestParam_1362739351228_895383.evaluate(calculator_TestParam_1362739351228_895383:223)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:190)
Your datasource expression $P{REPORT_DATA_SOURCE}).subDataSource("/B/C")
Has a syntax error
You missed unmatched character at first (
Then
If its expecting a JRSortableDataSource
Use this expression
((net.sf.jasperreports.engine.data.JRSortableDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("DefineThat")
If its expecting a JRXmlDataSource
Use this expression
((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("DefineThat")
$P{REPORT_DATA_SOURCE}).subDataSource("Xpath")
when somebody uses the above expression to connect to create sub report in Jasper using XML Datasource we need to set the Report Language as groovy instead of Java .I think subdatasource is not a method defined in Java but in groovy .I'm trying to find a method which is equivalent to above in Java
Had the same issue, found this solution at the jaspersoft-community:
Capturing the original data source in a parameter:
<parameter name="MyDataSource" class="net.sf.jasperreports.engine.JRDataSource" isForPrompting="false">
<defaultValueExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></defaultValueExpression>
</parameter>
same in iReport-GUI:
create new paramater at the main report
Name: "MyDataSource"
Parameter Class: "net.sf.jasperreports.engine.JRDataSource"
Use as a prompt: No
Default value Expression: "$P{REPORT_DATA_SOURCE}"
Now using the MyDataSource Parameter at the subreport-datasource:
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{MyDataSource}).dataSource("/Subreport/path")]]></dataSourceExpression>

Resources