Customized data in serenity report - serenity-bdd

I am trying to add version information which is displayed in the login page to the serenity report index.html.
The version information is captured in LoginPage.java. I see that I can use #Step method to include customized statements in the report.
Can someone please give me some details on how to use the #Step feature to include the message in index.html?
I am just starting to use serenity-bdd framework, So any help in this regard is greatly appreciated.
Thanks in advance!!

Did you mean this:
String first = "param1";
String second = "param2";
#Step("Test step with parameters: {0} and {1}.")
public void testStep(String first, String second)
// method body...
Report will display it as:
Test step with parameters: param1 and param2.
Otherwise, if you don't provide the {0} and {1}, it will look like this:
String first = "param1";
String second = "param2";
#Step("Test step with parameters")
public void testStep(String first, String second)
// method body...
Test step with parameters: param1, param2

We can use the following statement to print version information in the report:
String version = "3.4.12";
Serenity.recordReportData().withTitle("Version").andContents(version);

Related

Talend - Dynamic Column Name (Enterprise version)

Can anyone help me solve this case?
I have much file to process, two of them is like on below screenshot with my expected output.
I use this transformation on Talend: tFileList---tInputExcel---tUnpivotRow---tMap---tPostgresqlOutput
The output is different to my expected output. This is the screenshot of the output
Can anyone help me to reach my expected output which is like on my first picture above?
This will be pretty hard. You'd have to handle that as a text file. And whenever you found "store" value in the first column you'd update your type with the value.
Here's how I'd start:
Basically tJavaFlex begin piece would contain:
String col1Type
String colNType
main part:
if input_row.col0.equalsIgnoreCase("store") {
col1Type = input_row.col1;
col2Type = input_row.col2;
colNType = input_row.colN;
continue; /*(so this record will be Ignored for the rest of the components!)*/
}
output_row.col1Type = col1Type;
output_row.col1Value = Integer.valueOf(input_row.col1);
/*coz we have text and need numbers :( */
I think using propagate results will save you from writing down all the other fields.
And from here it would be very simple as you have key-type-value-type-value-type-value results.

How to pass variable to groovy code in Intellij IDEA live templates groovy script?

I have a groovyScript in my Intellij IDEA live template, like this :
groovyScript("D:/test.groovy","", v1)
on my D:/test.groovy i have a code like this:
if ( v1 == 'abc') {
'abc'
}
Now I want to pass v1 variable into test.groovy ,can any one help me how can I do this?
For exemplification purposes I made a live template which is printing a comment with the current class and current method.
This is how my live template is defined:
And here is how I edited the variableResolvedWithGroovyScript variable:
The Expression for the given variable has the follwing value:
groovyScript("return \"// Current Class:\" + _1 + \". Current Method:\"+ _2 ", className(),methodName())
As you can see, in this case the _1(which acts like a variable in the groovy script) takes the value of the first parameter which is the class name, and the _2 takes the value of the
second parameter which is the method name. If another parameter is needed the _3 will be used in the groovy script to reference the given parameter.
The arguments to groovyScript macro are bound to script variables named _1, _2 etc. This is also described at groovyScript help at Edit Template Variables Dialog / Live Template Variables.
I found a solution.
I was needing to calculate a CRC32 of the qualified class name using live models
I used it like this:
groovyScript("
def crc = new java.util.zip.CRC32().with { update _1.bytes; value };
return Long.toHexString(crc);
", qualifiedClassName())
then the result is
Based on the documentation, your variables are available as _1, _2, etc. Please note that variables are passed without dollar signs (so only v1 instead of $v1$)
So your test script should look like
if ( _2 == 'abc') {
'abc'
}

Passing different parameter und value in TestNG without xml file

I have test methods which should be started after TestData are set up. As the method for the set up is always the same I wanted to pass parameters to run different SQL Scripts.
#Test #Parameters("sqlScript") (groups = "insert_data")
public void testInsertData(String sqlScript) throws Exception {
final String methodName = "testInsertData";
scriptService.runSQL( sqlScript +".sql");
}
How can I do that without using testng.xml . I know there is an option called #Optional("CREATE TABLE T1 ....") , but with this I just can use one parameter. What if I want to pass the method SQL for Create table for T2, T3,....
You can use #DataProvider for this instead of #Parameters. Read more # Dataproviders

More than one datapool to a script in RFT

Is there any way can we add two datapools to a single script? Or in other words how can we get inputs from two different datapools to a single script.
Thanks in advance.
Yes, you can manually load and manage any number of datapools.
/**
* Creates a IDatapoolIterator pointing the first record
* #param datastore default project path
* #param dataPoolPath relative path in the project
* #return IDatapoolIterator pointing the first record
*/
public static IDatapoolIterator getDataPoolIterator(String datastore, String dataPoolPath)
{
java.io.File dpFile = new java.io.File(datastore, dataPoolPath+".rftdp");
DatapoolScriptSupport dss = new DatapoolScriptSupport();
IDatapool dp = (IDatapool) dss.dpFactory().load(dpFile, true);
IDatapoolIterator dpIter = dss.dpFactory().open(dp, null);
dpIter.dpInitialize(dp);
dpIter.dpReset();
return dpIter;
}
then in your code
myDatapool = getDataPoolIterator((String)getOption(IOptionName.DATASTORE), "relative/path/intheproject");
You can access any Variable in the datapool by
myDatapool.dpString("Variable");
Use the correct method depending the type of the variable you need. Using
myDatapool.dpNext();
you will advance to the next record in the datapool.
Hope this will help.
Further informations here: IBM Help System: Datapool

Looping in selenium

I recorded one script using Selenium IDE which contain clicking on a link and now i want to add loop to run same script multiple time, for this i am converting script to python but unable to add loop.Please help me in this regards.
Heres some text direct from selenium docs:
Data Driven Testing:
Data Driven Testing refers to using the same test (or tests) multiple times with varying data. These data sets are often from external files i.e. .csv file, text file, or perhaps loaded from a database. Data driven testing is a commonly used test automation technique used to validate an application against many varying input. When the test is designed for varying data, the input data can expand, essentially creating additional tests, without requiring changes to the test code.
# Collection of String values
source = open("input_file.txt", "r")
values = source.readlines()
source.close()
# Execute For loop for each String in the values array
for search in values:
sel.open("/")
sel.type("q", search)
sel.click("btnG")
sel.waitForPageToLoad("30000")
self.failUnless(sel.is_text_present("Results * for " + search))
Hope it helps. More info at: Selenium Documentation
Best Regards,
Paulo Bueno.
Try a loop similar to this example using "for x in range (0,5):" to set the number of times you wish it to iterate.
def test_py2webdriverselenium(self):
for x in range(0,5):
driver = self.driver
driver.get("http://www.bing.com/")
driver.find_element_by_id("sb_form_q").click()
driver.find_element_by_id("sb_form_q").clear()
driver.find_element_by_id("sb_form_q").send_keys("testing software")
driver.find_element_by_id("sb_form_go").click()
driver.find_element_by_link_text("Bing").click()
I tried this for some situations that I have little information:
list = [''' list containing all items ''']
index = 0
while True:
try:
# do what you want with list[index]
index += 1
except:
# index exception occured
break
In java you can do this as below:
# import packages or classes
public class testClassName(){
before test Methods(){
}
#Test
public void testMethod(){
for(int i =0, i<=5, i++){
WebElement element = driver.findElementById("link_ID");
element.click();
waitForPageLoaded(5);
}
}
after Test Method(){
}
}