找回密码
 加入
搜索
查看: 235|回复: 2

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

[复制链接]
发表于 2024-9-2 16:55:41 | 显示全部楼层 |阅读模式
本帖最后由 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后边加上()
 楼主| 发表于 2024-9-3 08:08:00 | 显示全部楼层
繁星 发表于 2024-9-2 22:51
得补习下基础知识咯,函数后边必须加括号,即使没有参数传递,_NowCalc后边加上() ...

感谢大佬,这么明显的错误自己竟然没有发现。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-22 01:23 , Processed in 0.082067 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表