Opt("TrayIconHide",1)
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <Excel.au3>
#include <GuiRichEdit.au3>
#include <..\MyInclude\wd_capabilities.au3>
#include <..\MyInclude\wd_helper.au3>
$Form1 = GUICreate("Web DEMO", 672, 377, 192, 124)
$Group1 = GUICtrlCreateGroup("Run Log", 8, 8, 657, 361)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$hRichEdit = _GUICtrlRichEdit_Create($Form1, "", 10, 10, 650, 355, BitOR($ES_MULTILINE, $WS_HSCROLL, $WS_VSCROLL, $ES_READONLY))
_GUICtrlRichEdit_SetCharColor($hRichEdit, 0xCC0000)
_GUICtrlRichEdit_AppendText($hRichEdit, "*************Web DEMO ************"&@CRLF)
_GUICtrlRichEdit_SetCharColor($hRichEdit, 0x666633)
_GUICtrlRichEdit_AppendText($hRichEdit, "Web DEMO......"&@CRLF)
_GUICtrlRichEdit_SetCharColor($hRichEdit, 0xCC0000)
_GUICtrlRichEdit_AppendText($hRichEdit, "*****************************************"&@CRLF)
_GUICtrlRichEdit_SetCharColor($hRichEdit, Default)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
web()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func web()
$ChromeDriver="D:\Program Files\chrome-win64\chromedriver.exe"
_GUICtrlRichEdit_AppendText($hRichEdit, _NowCalc&@TAB&"加载ChromeDriver...."&@CRLF)
WinKill("[title:" &$ChromeDriver )
_WD_Option('Driver', $ChromeDriver)
;_WD_Option('DriverParams', '--verbose --log-path="' &@ScriptDir &'\chrome.log"')
_WD_Option('Port', 9515) ;端口
Local $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}}'
_WD_Startup()
_GUICtrlRichEdit_AppendText($hRichEdit, _NowCalc&@TAB&"开始设定浏览器属性..."&@CRLF)
Dim $sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Window($sSession, "Maximize") ;最大化打开窗口
_GUICtrlRichEdit_AppendText($hRichEdit, _NowCalc&@TAB&"打开百度..."&@CRLF)
_WD_Navigate($sSession, "https://www.baidu.com")
MsgBox(0,"Notice!!","已经打开百度!!")
_WD_DeleteSession($sSession)
_WD_Shutdown()
Sleep(5000)
_GUICtrlRichEdit_AppendText($hRichEdit, _NowCalc&@TAB&"关闭Chrome!!"&@CRLF)
EndFunc