FitNesse getting the suite name in SuiteSetUp java Class - java

I have 2 pages a Suite page Suite1 and a SuiteSetUp page. Inside the suiteSetUp page I am calling a java constructor with the suite name as parameter.
now When I run my fitnesse suite I am getting the string 'SuiteSetUp' in java. I should get Suite1.. is it doable in FitNesse using java?
!|library |
|suite set up|${USERNAME}|${suiteName}|
suiteName is defined in a template which is included to this page
suiteName is defined as follows.
!define suiteName {${RUNNING_PAGE_NAME}}
this is how I included the template to the page the !define command is written inside the template page
!include -c .FrontPage._TEMPLATE

I guess you include the template page in the SuiteSetUp page, which means the RUNNING_PAGE_NAME will be "SuiteSetUp", thats why you are getting that value. (ok it may sound like I did not say anything... but that's a simple fact).
You can switch to RUNNING_PAGE_PATH or PAGE_PATH and perform string manipulation to retrieve the last token in java if you want to do it in a similar way.

Related

How to read properties of DOM object via selenium Java API?

I need to read some properties of a DOM object via the selenium Java API. I'll explain my requirement via an example.
Let's say first I would like to find the <g> element highlighted in the Chrome Developer Tools (as shown below). I can easily do so via the Selenium Java API with the following code.
WebElement gElement = driver.findElement(By.xpath("//*[#data-id='node_grp_0_id52UVV33EHE7']"));
Then I would like to read several properties of this <g> object via the Selenium Java API. So, I click on this <g> element in the Chrome Developer Tools and open the Properties view on the right hand side of the Chrome Developer Tools (as shown below) in order to find the path to various properties. After finding the paths, I now would like to read several of these properties (e.g. ariaChecked and __data__.label) via the Selenium Java API as shown below:
gElement.getAttribute("ariaChecked");
gElement.getAttribute("__data__.label");
Both the above mentioned lines of code returns null.
The following code also does not return the desired property values:
element.getCssValue("ariaChecked");
element.getCssValue("__data__.label");
Does anyone know how to read various properties of a DOM object (listed in the Properties view of the Chrome Developer Tools as shown below) via the selenium Java API?
Thanks in advance!
I've found a workaround to read a property of a web element via Java Script as shown below. Nested properties are also supported by this workaround:
public String getProperty(final String name) {
return getJavascriptExecutor().executeScript("return arguments[0]." + name + ";", webElement).toString();
}
The above method can be invoked as shown below:
String name = getProperty("name");
or
String label = getProperty("__data__.label"); // This is a nested property.

JMeter JSR233 result to dashboard

I have a JMeter test that insert an input via an HTTP call to an asynchronous java-service and then collects an exposed metric on another java-service via a groovy script.
The script then saves the collected metric as a JMeter variable to be reviewed as a performance metric.
I would like to publish this value inside the JMeter -generated dashboard but I can't find a way to save this variable as a JMeter output.
Is there a way? seems JMeter is primarily aimed to test HTTP synchronous services but it's capable of doing such collection of data.
You can use variable(s) in custom graph definitions:
You can graph any sample_variable in CSV over time, you can customize your graphs by settings their properties in the user.properties file.
They must use the id prefix custom_:
jmeter.reportgenerator.graph.custom_<your_graph_name_id>.property.<your_option_name>
To specify that this graph is a customized one :
jmeter.reportgenerator.graph.custom_<your_graph_name_id>.classname=org.apache.jmeter.report.processor.graph.impl.CustomGraphConsumer
Here is an example of a custom graph configuration that graphs the variable ts-hit:
jmeter.reportgenerator.graph.custom_testGraph.classname=org.apache.jmeter.report.processor.graph.impl.CustomGraphConsumer
jmeter.reportgenerator.graph.custom_testGraph.title=Chunk Hit
jmeter.reportgenerator.graph.custom_testGraph.property.set_Y_Axis=Number of Hits
jmeter.reportgenerator.graph.custom_testGraph.set_X_Axis=Over Time
jmeter.reportgenerator.graph.custom_testGraph.property.set_granularity=60000
jmeter.reportgenerator.graph.custom_testGraph.property.set_Sample_Variable_Name=ts-hit
jmeter.reportgenerator.graph.custom_testGraph.property.set_Content_Message=Number of Hits :
Declare the JMeter Variable you're saving in the JSR223 script as a Sample Variable, in order to do this add the next line to user.properties file:
sample_variables=foo
Then you can configure your custom chart like:
jmeter.reportgenerator.graph.custom_testGraph.classname=org.apache.jmeter.report.processor.graph.impl.CustomGraphConsumer
jmeter.reportgenerator.graph.custom_testGraph.title=Your custom chart title
jmeter.reportgenerator.graph.custom_testGraph.property.set_Y_Axis=Your Y axis name
jmeter.reportgenerator.graph.custom_testGraph.set_X_Axis=Over Time
jmeter.reportgenerator.graph.custom_testGraph.property.set_granularity=60000
jmeter.reportgenerator.graph.custom_testGraph.property.set_Sample_Variable_Name=foo
jmeter.reportgenerator.graph.custom_testGraph.property.set_Content_Message=Your custom content message
replace foo with the actual JMeter Variable name of your choice and next time you generate HTML reporting dashboard you should see your variable values plotted over time
More information:
Reporting configuration
Apache JMeter Properties Customization Guide

How can we get the results of assertion in Slim/Fitnesse

We have a fitnesse / slim table where in the fourth instruction is my assertion for the test case.is there a way we can get the result of this particular method as Pass or Fail.
For example
!|Fixture|
|method1|method2|method3|**method4**|
|res |res2 |res3 |**TCresult**|
For example here i want to know if method4 passed or failed.We have a different reporting system which cannot be done away with and every test case result needs to be validated.Also one test script have more that one test case in it.So we want the pass or fail of those methods which validate test cases.
script
given test page Testpage
and Test System setup is !define TEST_SYSTEM {slim}
!path lib/*.jar
and Setup content is
!|import|
|fitnesse.slim.test|
!|Scenario|Stop Test|
|start|ConstructorThrows|stop test|
!|Scenario|Not Executed|MESSAGE |
|check|echo|#MESSAGE|cannot fail #MESSAGE|
and Test content is
!|Script|
|Stop Test|
|Not Executed and should be ignored|
!|Script|
|Not Executed and should be ignored as well|
when page Testpage is tested and HTML is extracted
then \d assertions pass, 0 fail, 0 are ignored 1 exceptions thrown
and cell Stop Test has result error
and cell Not Executed and should be ignored has result ignore
and cell Not Executed and should be ignored as well has result ignore
and cell Test not run has result ignore
show Symbol $HTML_Input
show Symbol $HTML_Result
get collapsed executon log for page Testpage

Unable to write a simple step passing a single string as a parameter

I work with JBehave on a daily basis, but have been tasked with working on a project that uses Cucumber. In order to add a custom reporting class functionality to that project, I need to add two steps, one at the start of the feature (story) and another at the start of the scenario. I merely want to pass to the application a description of the feature/story and the scenario to be passed to the reporting module. I know that cucumber can access the scenario name through code, but that would only resolve one of the two lines - I would still need to have another one that passes the description of the feature/story.
What I've tried in the feature file:
Feature: Ecolab BDD Test Automation Demo
Scenario Outline: User can login and logout from the landing page
Given story "EcolabWebDemo_TestCases - Ecolab BDD Test Automation Demo"
Given scenario "User can login and logout from the landing page"
Given I am on the Ecolab landing page
The corresponding code for the two added Given statements at the beginning above:
#Given("^story {string}$") // \"(\\S+)\"
public void givenStory(String storyName) {
test.initStory(storyName); // will show on report in Features column
}
#Given("^scenario {string}$") // \"(\\S+)\"
public void givenScenario(String scenarioName) {
test.initScenario(scenarioName);
}
The commented regex patterns afterwards are the suggested ones I should try but do not seem to work either.
The current configuration at least seems to "find" the steps but reports:
cucumber.runtime.CucumberException:
java.util.regex.PatternSyntaxException: Illegal repetition near index
13 ^the scenario {string}$
So that's obviously not the solution. The regex used instead of {string} simply does not find a match and does not run.
regex is absolute Greek to me, not sure why it can't just be simple like the {string} option implied it would be in the cucumber documentation. I've been searching on-line for guidance for the better part of two days to no avail, I'm apparently not even sure what to be searching for.
Based on Grasshopper's suggestion, I updated the version of Cucumber from 1.2.0 to 1.2.5. I was prepared to change the pom.xml to use the 3.x versions but tried the latest of the specified libraries first, and it did report after an attempted run what the correct regex should be for the two steps I added.
#Given("^story \"([^\"]*)\"$")
and
#Given("^scenario \"([^\"]*)\"$")
Now that the project has a version that seems to recognize strings and also reports the missing steps, the project now runs as intended.
Thanks for your help, Grasshopper.

Suite for pages in Fitnesse Java

Hi i am trying for Test suite pages in Fitnesse.so my page is look like below if i hit suite button it have to suite all link and want to produce result .if i run a paritcular page its working good with Test Page .How suite page works ??
my question is whether we have to create java class for suite page or it automatically import our package in setup it will suite page i read through page but i cant get idea kindly help on this http://www.fitnesse.org/FitNesse.SuiteAcceptanceTests
http://stackoverflow.com/questions/10684735/how-to-include-all-ancestral-setup-pages-in-fitnesse-subwikis
which SuiteAcceptanceTests i have to use??? for my scenario
what I understood is In Setup we have to import our package it wil take care depanding on Folder.
My package is com.xx.xx
Apple
a
b
c
Ball
a
b
c
.....etc
Am Getting Error Like this
Test Summaries
org.apache.velocity.exception.MethodInvocationException: Invocation of method 'execute' in class fitnesse.responders.run.TestResponder$TestExecutor threw exception java.lang.StackOverflowError at suitePage.vm[line 23, column 15]
org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:261)
org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:187)
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280)
org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:369)
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
org.apache.velocity.runtime.directive.Parse.render(Parse.java:260) org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:207)
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
org.apache.velocity.Template.merge(Template.java:356)
org.apache.velocity.Template.merge(Template.java:260)
fitnesse.html.template.HtmlPage.render(HtmlPage.java:80)
fitnesse.responders.run.TestResponder.doSending(TestResponder.java:69)
fitnesse.responders.ChunkingResponder.startSending(ChunkingResponder.java:66)
fitnesse.http.ChunkedResponse.sendTo(ChunkedResponse.java:25)
fitnesse.FitNesseExpediter.sendResponse(FitNesseExpediter.java:94)
fitnesse.FitNesseExpediter.start(FitNesseExpediter.java:46)
fitnesse.FitNesseServer.serve(FitNesseServer.java:24)
fitnesse.FitNesseServer.serve(FitNesseServer.java:17)
fitnesse.socketservice.SocketService$ServerRunner.run(SocketService.java:99)
java.lang.Thread.run(Thread.java:745)
From the exception stack trace, it looks pretty similar to the Github discussion here.
A page that includes itself, for example, in the content.txt of page .SuitePage.TestPage, you have
!include .SuitePage.TestPage
This can cause the StackOverflowError you see. Check your !includes carefully and see whether it fixes your problem.

Categories