For handling Dialog boxes which are not web based, Then Autoit is the best
Tool to handle this
These are the following code should written in Selenium
Selenium Code:
try {
String[] commands = new String[] {};
commands = new String[] { "Path" }; // location of Autoit EXE file
Runtime.getRuntime().exec(commands);
} catch (IOException e) {
}
Autoit code:
if WinWaitActive("File Upload") Then
;MsgBox(2,"window found","Found the window")
WinActivate("File upload")
Send("!n")
Sleep(5000)
Send("File path")
SEND("{ENTER}")
;location of the file you want to a to the form and submit
;Send("!O")
Else
MsgBox(1,"TimeOut","Timed out")
EndIf
Here we need to create a Exe file for the Autoit script and that path
should be mentioned in selenium code.
The Reflection API allows Java code to examine classes and objects at run time.The new reflection classes allow you to call another class's methods dynamically at run time. With the reflection classes, you can also examine an instance's fields and change the fields' contents. The Reflection API consists of the java.lang.Class class and the java.lang.reflect classes: Field, Method, Constructor, Array, and Modifier. Example program: import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; // calling method whose name we store in a variable public class ReflectionAPI { public static void main(String[] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { String x="sampleTest"; //String meth=read name from xls file Method method= ReflectionAPI.class.getMethod(x, String.class); method.invoke(method, "welcome"); System.out....
Comments
Post a Comment