#include "wd_helper.au3"
#include "wd_capabilities.au3"
Global $_WD_DEBUG = 0 ; You could also use $_WD_DEBUG_Error
Global $_DEBUG = ["OFF", "WARNING", "INFO", "ALL"]
Global $sDesiredCapabilities, $sSession, $sElement
Global $ResSU, $ResSUE
_WD_UpdateDriver("Chrome")
$sDesiredCapabilities = SetupChrome(False)
$ResSU = _WD_Startup()
$ResSUE = @error
If $ResSU = 0 Then Exit MsgBox(262144, "", "Result Startup = " & $ResSU & " " & "Error = " & $ResSUE)
QQDown()
Func QQDown()
Local $XPath, $sSession, $sElement, $sRes
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_SetTimeouts($sSession, '{"pageLoad":10000}')
_WD_Navigate($sSession, "https://im.qq.com/pcqq")
$XPath = '//*[@class="btn-downlond"]/a'
$sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $XPath) ;等待按钮加载
$sRes = @error
Sleep(250)
If $sRes = $_WD_ERROR_Success Then
_WD_ElementAction($sSession, $sElement, 'click');点击按钮
MsgBox(0,"","点击了下载按钮")
Sleep(2000)
EndIf
_WD_DeleteSession($sSession)
_WD_Shutdown($ResSU)
EndFunc ;==>Fanyi
Func SetupChrome($Head)
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-level=' & $_DEBUG[$_WD_DEBUG] & ' --log-path="' & @ScriptDir & '\chrome.log"')
_WD_CapabilitiesStartup()
_WD_CapabilitiesAdd('alwaysMatch', 'chrome')
_WD_CapabilitiesAdd('excludeSwitches', 'enable-automation')
_WD_CapabilitiesAdd('excludeSwitches', 'load-extension')
;_WD_CapabilitiesAdd('args', "--guest")
If $Head Then
_WD_CapabilitiesAdd('args', '--headless') ;无头模式
EndIf
_WD_CapabilitiesAdd('binary', _WD_GetBrowserPath("chrome")) ; 设置浏览器路径
_WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing in this demo
Local $sCapabilities = _WD_CapabilitiesGet()
Return $sCapabilities
EndFunc ;==>SetupEdge
|