kemyliu 发表于 2024-9-2 16:55:41

帮忙看一下ChromeDriver控制浏览器后RichEdit就无法再显示新增内容【已解决】

本帖最后由 kemyliu 于 2024-9-3 08:08 编辑

各位大佬,如题:
帮忙看一下ChromeDriver控制浏览器后RichEdit就无法再显示新增内容,哪位大神帮忙一下!!

Au3 Webdriver下载地址:
Release 1.3.1 · Danp2/au3WebDriver · GitHub

ChromeDriver下载网址:
Chrome for Testing availability (googlechromelabs.github.io)
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



繁星 发表于 2024-9-2 22:51:59

得补习下基础知识咯,函数后边必须加括号,即使没有参数传递,_NowCalc后边加上()

kemyliu 发表于 2024-9-3 08:08:00

繁星 发表于 2024-9-2 22:51
得补习下基础知识咯,函数后边必须加括号,即使没有参数传递,_NowCalc后边加上() ...

感谢大佬,这么明显的错误自己竟然没有发现。
页: [1]
查看完整版本: 帮忙看一下ChromeDriver控制浏览器后RichEdit就无法再显示新增内容【已解决】