I have the script in AutoIT (to handle upload file window in selenium)
WinWaitActive("File Upload")
Send("C:\Users\XXX\Desktop\Folder1\MyFile.xlsx")
Send("{ENTER}")
Instead of hard-coding pathname, I want to pick-up pathname from a property file.(So that tomorrow we dont to touch AutoIT script to modify pathname).
Is there any way to do so?
Update 1:
java code:
Runtime.getRuntime().exec(TestUtility.properties.getProperty("test.all.autoit.testdata"));
Thread.sleep(8000);
AutoIT code:
WinWaitActive("File Upload")
Send($CmdLine[1])
Send("{ENTER}")
Cmd line:
c:>java -jar pathToJar.jar pathToProperties.properties pathToFileUpload.xlsx
Properties file:
test.all.autoit.testdata='C:\\XX\\XX\\XX\\someFolder\\ListUploadScript.exe'
What I've done is AutoIt script can accept command line parameter for invoking so my Java test use to read that property from properties file and then when I invoke AutoIt script I invoke it with the property as command line option to the AutoIt script and accept that command line argument in AutoIt script as the path to the file to be uploaded. Let me know if this works for you!!!
Also if your upload button is of type input then no need use AutoIt..directly element.sendKeys(<Path to upload file>) should work
Sample Code:
WinActivate("File Upload")
WinWaitActive("File Upload")
Send($CmdLine[1])
Send("{Enter}")
Here $CmdLine[1] accepts the first command line argument passed. so while calling this script (.exe) call it in this way.
Runtime.getRuntime().exec("src/test/resources/fileupload.exe "+path);
where path is the path to the file which you wish to upload.
I assume you would already know when to call your AutoIt script :D
EDIT1 : $CmdLine[0] is reserved to get count of number of command line arguments passed to autoit script..so the actual arguments start with $CmdLine[1] which is the first argument passed on command line.
EDIT2: I am assuming you are running from a main method, if so then your call to execute autoIt script should be like this: Runtime.getRuntime().exec(TestUtility.properties.getProperty("test.all.autoit.testdata")+" "+args[0]);
where args[0] is the args array passed as argument to main method whose 0th Index has excel sheet which you wish to pass. Also you need to pass absolute path of the excel spreadsheet.
You can use ini files with IniRead and IniWrite functions
The file look like :
[SectionName]
KeyName1=Value
KeyName2=Value
And you read in the file with :
IniRead('nom_fichier.ini', 'SectionName', 'KeyName1', 'Default Value')
Related
I'm using the Nintendo 64 emulator, Mupen64Plus.
It has a file called mupen64plus-ui-console.exe used to launch games through command-line. It also accepts keyboard shortcuts to perform commands, but it is limited.
Mupen64Plus Commands/Functions
This wiki page shows a list of all commands that can be called, I think from the mupen64plus.dll.
RUNDLL32
I read how to pass commands to a dll like this:
RUNDLL32.EXE <dllname>,<entrypoint> <optional arguments>
Calling a Command with RUNDLL32
I'm trying to call M64CMD_STATE_LOAD with cmd.exe, to load a save file.
Info from Wiki:
Command Functions Prototype m64p_error CoreDoCommand(m64p_command
Command, int ParamInt, void *ParamPtr)
ParamInt Ignored ParamPtr Pointer to string containing state file path
and name, or NULL
This command will attempt to load a saved state file. If ParamPtr is
not NULL, this function will load a state file from a full pathname
specified by this pointer. Otherwise (ParamPtr is NULL), it will load
from the current slot.
I have the Mupen64Plus emulator running a game. I then open cmd.exe and paste in this line.
RUNDLL32.EXE "C:\Path\To\mupen64plus.dll", CoreDoCommand M64CMD_STATE_LOAD 1 "C:\Path\To\MySave.m64p"
Problem
It accepts the command, I get no errors, but the save file isn't loaded.
Questions
Are the arguments being passed wrong?
Does the mupen64plus.dll not have hooks into the currently running mupen64plus-ui-console.exe?
Is it loading the save file into nothing?
Is it not possible to do it this way?
I have a config.property file that contains all the property values to be used in jmeter, so i am using property file reader plugin to read the property file, here the problem is i don't want to hard code the path to config.properties file in property file reader so i want it to pass as command line argument but it is not working
command i am executing is
.\jmeter -JPROPERTY_FILE=<file_location> -n -t <path_to_jmx> -l <path_to_jtl> -j <path_to_log>
In the File Path of Property File Reader, replace:
${PROPERTY_FILE}
By using __P function:
${__P(PROPERTY_FILE)}
Your mistake is that you’re using Variable syntax for a property.
See:
http://jmeter.apache.org/usermanual/functions.html#__P
http://jmeter.apache.org/usermanual/functions.html#functions
You should be using __P() function like ${__P(PROPERTY_FILE)} or even __property() function like ${__property(PROPERTY_FILE,PROPERTY_FILE)}. The latter one automatically stores the retrieved value into a JMeter Variable so you won't have to additionally declare it under User Defined Variables of the Test Plan
Instead of using custom plugins I would suggest going for built-in JMeter functionality, there is -q command-line argument which allows loading and arbitrary .properties file so you will not have to install the plugin, care about order of Configuration Elements, etc.
I have written some code which runs a script using wscript.exe.
Set oShell = CreateObject("Shell.Application")
oShell.ShellExecute "wscript.exe", strPath2Script, , "runas", 1
Key to this is the "runas" which allows us to run as an admin. This all works fine, but I also have to have additional code elsewhere to create a script file. This seems like a waste, and I would prefer to just send in the code in the file located at strPath2Script as a parameter to wscript.
It doesn't seem like that is possible, and if I have to generate the script, so be it, but is it possible to just send code as a string into wscript.exe rather than have to provide a path to a text file which has the script code?
Thanks for any insights.
Chris
No, you can't just pass code into wscript.exe or cscript.exe. You'll have to write it to a file and pass the filename to wscript.exe or cscript.exe.
Hi i am trying to set a variable in my .bat file and i want to use the variable in sqlldr code to state the file (infile)
This is what i have in my bat file for the variable:
set directroy_name= D:\Folder\Folder\Folder\File.csv
Then in my command file i have
load data
infile '%directory_name%'
When ever i try to run the .bat file from the command prompt i just receive the SQL_Loader_500: unable to ope file (%directory_name%.dat
I know the files in the correct location?
any ideas why its doing this?
No, you can't do that - you're expecting the Oracle executable to understand Windows environment variable syntax. If it did that it would have to deal with $ variables in Unix, etc.
You can just pass the file name on the command line instead. In your control file omit the INFILE altogether, then when you call SQL*Loader add a a DATA command-line argument:
sqlldr user/password CONTROL=your.ctl DATA=%directory_name% ...
Assuming your variable is just oddly named and does have a full file path as you've shown.
If it's present, the INFILE argument will be overridden by the command-line argument, so you could include a default fixed value if you wanted to, I suppose.
You also appear to have a typo; you set directroy_name, but then use directory_name, which will have no value. You need to change that to:
set directory_name= D:\Folder\Folder\Folder\File.csv
To run a CUDA C program we build the program and then run the binary file created from the command line as
/.prgm_bin_file
If for example the program needs some input files like for programs to image processing, I want to supply the data files or the input files at the time of compilation.
How can I do that. How the above command can be edited to give the required files.
Thanks in advance.
If your program opens data files to use for input, it's using some file I/O API to do so. For example, one possible method is to use fopen.
Just to use it as an example, if you are using fopen, it expects a filename (a character string) passed as the first parameter.
Many programs will take this filename from a the command line used to invoke the program. But there's nothing that would prevent you from hard-coding the filename:
fp=fopen("mydata", "r");
In that case, the program would always attempt to open the file mydata
But if your program is already designed to use the filename as a command line parameter, it's not clear that this is any more useful than just invoking your program that way:
./prgm_bin_file mydata