Selenium using AUTOIT3 to process Windows controls

Source: Internet
Author: User

Selenium itself cannot handle windows controls, and requires the help of AutoIt
AUTOIT3 syntax is simple, such as the Windows dialog box that handles uploading files

Controlfocus ("Please select Upload file", "", "Edit1")
Controlsettext ("Please select Upload file", "" "," Edit1 "," D:\upload.txt ")
Sleep (2000)
Controlclick ("Please select Upload file", "", "Button1");
These methods are basically similar in syntax:
First parameter: Title/hwnd/class
Controlclick ($hWnd, "", "Edit1")
Controlclick ("title", "", "Edit1")
Controlclick ("[CLASS: #32770]", "", "Edit1")

Controlid:id text,class,classnn,name,instance
such as: button1; [Id:1003];1003 (ID), "[Classnn:edit1]", "Save (&s)", [Class:button;instance:1], "[Name:textboxfolder]",


For example: The above statement can also be written like this
Controlfocus ("[CLASS: #32770]", "", "Edit1")
$hwnd =winwait ("[CLASS: #32770]", "", 5)
Controlsettext ($hwnd, "", "Edit1", $filename)
Sleep (2000)
Controlclick ("[CLASS: #32770]", "", "Save (&s)")

If you need to pass parameters, you need to encapsulate the function, the AutoIt parameter form is: $CmdLine [0] is the number of arguments, $CmdLine [1] represents the first parameter, and so on, such as multiple parameters, called, when the middle with a space split, such as Upload.exe param1 Param2
SaveAs ($CmdLine [1])
Func SaveAs ($filename)
Winactve ("[CLASS: #32770]")
Controlfocus ("Please select Upload file", "", "Edit1")
Controlsettext ("Please select Upload file", "", "Edit1", $filename)
Sleep (2000)
Controlclick ("Please select Upload file", "", "Button1");
Endfunc
Converted to an EXE file, you can directly invoke the

Java calls:
public static void SaveFile (String filepath) {
String command = "E:\\upload.exe" + "" +filepath;
try {
Runtime.getruntime (). exec (command);
} catch (IOException e) {

E.printstacktrace ();
}
}

Of course QTP can also be called:
CreateObject ("Wscript.Shell"). Run "D:\upload.exe"

Selenium using AUTOIT3 to process Windows controls

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.