I use Selenium Web Driver in Eclipse with JUnit. I compose my main test - common for all other, on the begining I set my input data (which is different for each test):
String update_f="//*[#id='columnTitle2']/input";
String update_u="dscr";
String name_p="Test";
String[] link=new String [] {"001","01"};
String[] lov_name= new String [] {"Work","Machine"};
Is it possible to set this data in excel file and than just change this file if I want execute specific test (actually set specific data)?
It is possible my friend,with the help some external jars to handle Excel spread sheets.
U can choose
a. JXL Jar ( which is easy to use and is sufficient for normal functionalities like read and write) - http://www.andykhan.com/jexcelapi/tutorial.html
b. Apache poi jar - http://onjava.com/pub/a/onjava/2003/04/16/poi_excel.html
Add these external jars into eclipse.
create an excel file with different input values.
Read and pass these values from excel through the jars.
currently im working with JXL it is good.
Related
I want to create a parameter that contains a list of string (list of hub codes). This list of string is created by reading an external csv file (this list could contain the different codes depending on the hub codes in the CSV file)
What I want is to find a easy auto way to perform batch runs by each hub code in the list.
So this question is:
1) how to add and set a new parameter directly from the code (during the initialization when reading the CSV) instead of GUI parameter panel?
2) how to avoid manual configuration of hub list in the batch run configuration
Something like this for adding the parameters should work in your ContextBuilder.
Parameters params = RunEnvironment.getInstance().getParameters();
((DefaultParameters)params).addParameter("foo", "Big Foo", Integer.class, 3, false);
You would read the csv file to get the parameter name and value.
I'm not sure I completely understand the batch run configuration question, but each batch run has a run number associated with it
RunState.getInstance().getRunInfo().getRunNumber()
If you can associate line numbers in your csv parameter file with run number (e.g. run number 1 should use line 1, and so on), then each batch run would use a different parameter line.
I am new-ish to Selenium, so I use Katalon Automation Recorder through Chrome to quickly draft scripts.
I have a script that makes an account on a website, but I want to make more than one account at a time (using a catchall). Is there a way for Selenium/Katalon to alternate its input from a database of preset emails (CSV sort of thing) or even generate random values in-front of the #domain.com each time the script loops over?
Here is the current state of the script:
Thanks
As #Shivan Mishra mentioned, you have to do some data driven testing. In Katalon you can created test data in object repository (See https://docs.katalon.com/katalon-studio/docs/manage-test-data.html)
You can manage your test data in script like following example:
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
def data = findTestData('path/to/your/testdata/in/object repository')
for(int=0;i<data.getRowNumbers();i++){
def value = data.getValue(1, i)
// do any action with your value
}
I need to write to a non-VSAM dataset in the mainframe. I know that we need to use the ZFile library to do it and I found how to do it here
I am running my Java batch job in the WebSphere Liberty on zOS. How do I specify the dataset? Can I directly give the DataSet a name like this?
dsnFile = new ZFile("X.Y.Z", "wb,type=record,noseek");
I am able to write it to a text file on the server itself using Java's File Writers but I don't know how to access a mvs dataset.
I am relatively new to the world of zOS and mainframe.
It sounds like you might be asking more generally how to use the ZFile API on WebSphere Liberty on z/OS.
Have you tried something like:
String pdsName = ZFile.getSlashSlashQuotedDSN("X.Y.Z");
ZFile zfile = new ZFile(pdsName , ...options...)
As far as batch-specific use cases, you might obviously have to differentiate between writing to a new file that's created for the first time on an original execution, as opposed to appending to an already-existing one on a restart.
You also might find some useful snipopets in this doctorbatch.io repo, along with the original link you posted.
For reference, I'll copy/paste from the ZFile Javadoc:
ZFile dd = new ZFile("//DD:MYDD", "r");
Opens the DD namee MYDD for reading
ZFile dsn = new ZFile("//'SYS1.HELP(ACCOUNT)'", "rt");
Opens the member ACCOUNT from the PDS SYS1.HELP for reading text records
ZFile dsn = new ZFile("//SEQ", "wb,type=record,recfm=fb,lrecl=80,noseek");
Opens the data set {MVS_USER}.SEQ for sequential binary writing. Note that ",noseek" should be specified with "type=record" if access is sequential, since performance is greatly improved.
One final note, another couple useful ZFile helper methods are: bpxwdyn() and getFullyQualifiedDSN().
In a data-driven framework, we use Selenium along with TestNG to run multiple tests in parallel. How can the same be implemented in a keyword-driven framework?
In data-driven approach we can define every test case as a separate method and therefore we are able to command TestNG via annotations which methods to run and how many to run in parallel.
In keyword-driven approach, every test case is a separate Excel Sheet and multiple excel sheets in the same workbook make a test suite. How can these excel sheets/test cases be annotated/referred so as to run in parallel similar to the execution structure and process in data-driven framework?
One lame solution I thought of was a hybrid approach wherein creating methods which would call the excel sheet.
For eg.:
#Test
public void TestCase_001() {
// Read the keyword driven test case
// XLS_WorkbookName - The Excel Workbook or Test Suite containing multiple Test Cases
// XLS_SheetName - The Excel Sheet containing set of rows each of which contains ID of element, Operation to be performed and data to be used
ReadAndExecuteTestCase(XLS_WorkbookName_XYZ, XLS_SheetName_ABC);
}
#Test
public void TestCase_002() {
// Read the keyword driven test case
// XLS_WorkbookName - The Excel Workbook or Test Suite containing multiple Test Cases
// XLS_SheetName - The Excel Sheet containing set of rows each of which contains ID of element, Operation to be performed and data to be used
ReadAndExecuteTestCase(XLS_WorkbookName_ABC, XLS_SheetName_XYZ);
}
I'm not sure if they above example is the appropriate way to go about it. Requesting suggestions to the same. Thanks in advance.
One solution can be :
Have a master sheet of cases to execute, which acts as your suite.
Have your dataprovider read this master sheet and have a single #Test method which takes in the arguments of the testcase data.
This testcase basically reads the steps and executes - something like your ReadAnExecureTestCase method.
Make this dataprovider parallel and control using dataprovider thread count.
for some test I need to run a data driven test with a configuration that is generated (via reflection) in the ClassInitialize method (by using reflection). I tried out everything, but I just can not get the data source properly set up.
The test takes a list of classes in a csv file (one line per class) and then will test that the mappings to the database work out well (i.e. try to get one item from the database for every entity, which will throw an exception when the table structure does not match).
The testmethod is:
[DataSource(
"Microsoft.VisualStudio.TestTools.DataSource.CSV",
"|DataDirectory|\\EntityMappingsTests.Types.csv",
"EntityMappingsTests.Types#csv",
DataAccessMethod.Sequential)
]
[TestMethod()]
public void TestMappings () {
Obviously the file is EntityMappingsTests.Types.csv. It should be in the DataDirectory.
Now, in the Initialize method (marked with ClassInitialize) I put that together and then try to write it.
WHERE should I write it to? WHERE IS THE DataDirectory?
I tried:
File.WriteAllText(context.TestDeploymentDir + "\\EntityMappingsTests.Types.csv", types.ToString());
File.WriteAllText("EntityMappingsTests.Types.csv", types.ToString());
Both result in "the unit test adapter failed to connect to the data source or read the data". More exact:
Error details: The Microsoft Jet database engine could not find the
object 'EntityMappingsTests.Types.csv'. Make sure the object exists
and that you spell its name and the path name correctly.
So where should I put that file?
I also tried just writing it to the current directory and taking out the DataDirectory part - same result. Sadly, there is limited debugging support here.
Please use the ProcessMonitor tool from technet.microsoft.com/en-us/sysinternals/bb896645. Put a filter on MSTest.exe or the associate qtagent32.exe and find out what locations it is trying to load from and at what point in time in the test loading process. Then please provide an update on those details here .
After you add the CSV file to your VS project, you need to open the properties for it. Set the Property "Copy To Output Directory" to "Copy Always". The DataDirectory defaults to the location of the compiled executable, which runs from the output directory so it will find it there.