We are using selenium to do automation on our web application. We have knowledge of CUIT.In CUIT we have process synchronization like WaitForReadyLevel.AllThreads,WaitForReadyLevel.UIThread.I want to know is there any way to achieve similar functionality using selenium?
I need some process synchronization after every step in my script for web application or is there any external APIs to achieve this.
Regards,
Raj.
We are using this process in our automation scripts to check whether process is busy or not.Hope this piece of code gives you a idea for your requirement.
bool isSync = true;
while (isSync)
{
using (PerformanceCounter pcProcess = new PerformanceCounter("Process", "% Processor Time",ProcessName))
{
pcProcess.NextValue();
Thread.Sleep(100);
if (!IsProcessRuning()) return rc;
double pct = pcProcess.NextValue();
if (pct == 0.0)
isSync = false;
}
}
Regards,
Nagasree.
Related
I have done till creation of proxy sever.Facing some socket broken issue on running the scripts in firefox
When i perform some actions everything is working then some error occurs
also explain what is jmeter tree model and jmeternode is?
Scanner sc = new Scanner(System.in);
// recordingController recordingcontroller=new recordingController("testrecorder",RecordController.class);
// RecordingController rc= (RecordingController) recordingcontroller.buildTestElement();
RecordingController rc = new RecordingController();
GenericController gc = new GenericController();
rc.initialize();
gc.addTestElement(rc);
LoopController loopController = new LoopController();
loopController.setLoops(1);
loopController.setFirst(true);
loopController.setProperty(TestElement.TEST_CLASS, LoopController.class.getName());
loopController.setProperty(TestElement.GUI_CLASS, LoopControlPanel.class.getName());
loopController.initialize();
rc.addTestElement(loopController);
ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setName("Thread-Group");
threadGroup.setSamplerController(loopController);
ProxyControl proxyController = new ProxyControl();
// proxyController.setProperty(TestElement.TEST_CLASS, ProxyControl.class.getName());
// proxyController.setProperty(TestElement.GUI_CLASS, ProxyControlGui.class.getName());
proxyController.setName("Proxy Recorder");
proxyController.setPort(4444);
// threadGroup.setSamplerController(rc);
// proxyController.setSamplerTypeName("SAMPLER_TYPE_JAVA_SAMPLER");
TestPlan testPlan = new TestPlan("My_Test_Plan");
testPlan.addTestElement(threadGroup);
testPlan.addTestElement(proxyController);
JMeterTreeModel jtm = new JMeterTreeModel();
proxyController.setNonGuiTreeModel(jtm);
JMeterTreeNode node = new JMeterTreeNode(proxyController,jtm);
// JMeterTreeNode node=new JMeterTreeNode();
proxyController.setTarget(node);
// proxyController.setCaptureHttpHeaders(true);
// proxyController.setUseKeepAlive(true);
// proxyController.setGroupingMode(4);
proxyController.setCaptureHttpHeaders(true);
proxyController.setProxyPauseHTTPSample("10000");
proxyController.setSamplerFollowRedirects(true);
proxyController.setSslDomains("www.geeksforgeeks.org");
proxyController.startProxy();
I don't think non-GUI proxy recording is something you can achieve with vanilla JMeter, if you have to automate the recording process you will have to go for desktop applications automation solutions like Appium or LDTP
If you need to record a JMeter script using Firefox on a system which doesn't have GUI I can think of following approaches:
Use Proxy2JMX Converter module of Taurus tool
Use BlazeMeter Proxy Recorder (by the way it has nice feature of exporting recorded scenarios in "SmartJMX" mode with automatic detection and correlation of dynamic parameters)
i am glad with the use of Karate DSL for API testing. But i was wondering if it is suited for test data generation. Some of our UI tests need some particular data load which I think could be generated by calling the API (Rest and SOAP) through Karate DSL.
Is Karate adequate for this or would you use other specific data generation tool?
Thanks in advance for your help.
I suggest you start looking at the new RC version (0.9.9.RC3) you can use a function to generate data: https://github.com/intuit/karate/tree/develop#json-function-data-source
* def generator = function(i){ if (i == 20) return null; return { name: 'cat' + i, age: i } }
I am using QAF as my Test Automation Framework.
I want to skip specific teststep in the production environment. How can I skip execution of BDD teststep using TestStepListener?
Here is an example use case:
For shopping cart application I have developed 200+ scenarios. I was executing all scenarios on the test environment. Now I want to execute all scenarios on production environment. Now I want to skip last steps of payment and order review on production environment. How can I do that?
Will you please provide details of use case? If my understanding is correct you don't want to execute specific step in the production environment. You can use step listener to jump to specific step index but not to skip current step. One of the way is group steps to high-level step. For example instead of writing detailed steps in bdd
Given some situation
When performing some action
Then step-1
And step-2 not for production
and step-3
You can have high level step
Given some situation
When performing some action
Then generic step for all environments
Here your generic step for all environments step can have implementation for different environments in different package. configure step provider package at runtime.
Another trick is set and reset dry-run mode in step listener. For example, in your step definition you can provide additional meta-data. In the step listener depends on meta-data if require set dry-run mode in before method and reset it after in method.
Step definition:
#MetaData("{'skip_prod':true}")
#QAFTestStep(description = "do payment")
public static void doPayment() {
//TODO: write your code here
}
Step listener code may look like:
public void beforExecute(StepExecutionTracker stepExecutionTracker) {
Map<String, Object> metadata = stepExecutionTracker.getStep().getMetaData();
if (null != metadata && metadata.containsKey("skip_prod") && "prod".equalsIgnoreCase(getBundle().getString("env"))) {
//do not run this step
getBundle().setProperty(ApplicationProperties.DRY_RUN_MODE.key,true);
}
}
public void afterExecute(StepExecutionTracker stepExecutionTracker) {
Map<String, Object> metadata = stepExecutionTracker.getStep().getMetaData();
if (null != metadata && metadata.containsKey("skip_prod") && "prod".equalsIgnoreCase(getBundle().getString("env"))) {
// this is not dry run so reset
getBundle().setProperty(ApplicationProperties.DRY_RUN_MODE.key,false);
}
}
I wanted to check how long service take to generate the data.
i am using Jmeter but it shows only Sample time (ms) and not the waiting time or content download time.
I hvae check in Chrome-developer tool but i need some automation and assertion for response (i am looking for tool to do it. )
It will be grate help if anyone knows how to check in Jmeter or with anyother tool.
Thank you in advance.
You can try out WebDriver Sampler which provides JMeter integration with Selenium, you will be able to use Navigation Timing API to get the metrics you're looking for like:
WDS.sampleResult.sampleStart()
WDS.browser.get('http://jmeter.apache.org')
var timings = WDS.browser.executeScript('var performance = window.performance || window.webkitPerformance || window.mozPerformance || window.msPerformance || {}; var timings = performance.timing || {}; return timings;');
var vars = org.apache.jmeter.threads.JMeterContextService.getContext().getVariables()
vars.put('connectStart', timings.connectStart)
vars.put('loadEventStart', timings.loadEventStart)
//etc
WDS.sampleResult.sampleEnd()
You will be able to access extracted variables like:
${connectStart}
${loadEventStart}
etc.
and use them in calculations, assertions or whatever.
See The WebDriver Sampler: Your Top 10 Questions Answered article for more WebDriver Sampler related tips and tricks
I have written a custom record reader and looking for sample test code to test my custom reader using MRUnit or any other testing framework. Its working fine as per the functionality but I would like to add test cases before I make an install. Any help would be appreciable.
In my opinion, a custom record reader is like any iterator. For testing my record reader I have been able to work without MRUnit or any other hadoop junit frameworks. The test executes quickly and the footprint is small too. Initialize the record reader in your test case and keep iterating on it. Here is a pseudocode from one of my tests. I can provide you more details if you want to proceed in this direction.
MyInputFormat myInputFormat = new MyInputFormat();
//configure job and provide input format configuration
Job job = Job.getInstance(conf, "test");
conf = job.getConfiguration();
// verify split type and count if you want to verify the input format also
List<InputSplit> splits = myInputFormat.getSplits(job);
TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID());
RecordReader<LongWritable, Text> reader = myInputFormat.createRecordReader(splits.get(1), context);
reader.initialize(splits.get(1), context);
for (; number of expected value;) {
assertTrue(reader.nextKeyValue());
// verify key and value
assertEquals(expectedLong, reader.getCurrentKey());
}