Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1449

Control the Chrome browser with Chromdirver for web page automation

$
0
0
Control the Chrome browser with Chromdirver for web page automation


There are a lot of similar codes, but very few pure VB ones. This is the code I used to write by referring to other people's code and fumbling through it. FYI. If there are errors, fix them. It is recommended to use Chrome 68.0.3440.75 to pass the test

Chromedirver.exe and Chrome.exe put it in the same directory
-bas
-cls
-Chrome---- 68.0.3440.75
----Dictionaries
-----Profile 1
-----chrome.exe
-----chromedriver.exe ***must can usde for your Chrome.EXE the version you use
-ChromeControl.vbp


If you are using a newer version of Chrome, please modify ChromeOptions.CLS .

It can be replaced with the code below

Code:

Private Sub Class_Initialize()
    Set Jb = New JsonBag
   
    mChromeOption = "{'desiredCapabilities':{'browserName':'chrome', "
    mChromeOption = mChromeOption & "'proxy':{'proxyType':'system','autodetect':'false','httpProxy':'127.0.0.1:8080','ftpProxy':'127.0.0.1:8080','sslProxy':'127.0.0.1:8080','noProxy':'','socksUsername':'cake','socksPassword':'madewithcake'},"
    mChromeOption = mChromeOption & "'version':'','loggingPrefs': "
    mChromeOption = mChromeOption & " {'browser':'ALL','driver':'ALL','performance':'ALL'}, "
    mChromeOption = mChromeOption & "'platform':'ANY','goog:chromeOptions':{'extensions':[],'prefs':{ 'credentials_enable_autosignin': true, 'credentials_enable_service': false,'last_clear_browsing_data_tab':1, "
    mChromeOption = mChromeOption & "'browser':{'check_default_browser':false,'clear_data':{'browsing_history_basic':true,'cache_basic':true,'cookies_basic':true}}, "
    mChromeOption = mChromeOption & "'profile':{'managed_default_content_settings':{'images':1,'popups':1},'autofill': { 'enabled': true,'orphan_rows_removed': true},'default_content_setting_values':{'sound':1}}, "
    mChromeOption = mChromeOption & "'download':{'default_directory':'C:\\','directory_upgrade':true,'prompt_for_download':true},'savefile':{'default_directory':'C:\\'}}, "
    mChromeOption = mChromeOption & "'args':['--disable-infobars','--disable-javascript','--window-size=600,500']}}}"
    Debug.Print Replace$(mChromeOption, "'", Chr(34))
   
    Jb.JSON = Replace$(mChromeOption, "'", Chr(34))
   
End Sub

The code used is widely referenced by the open source masters in the forum, such as dilettante, wqweto, Elory, scmidt and many others.Thanks for sharing

If you have any questions about Chromedirver, please do your own searching, as it is difficult for us to use external apps such as google due to network restrictions

It is possible to get the commands and formats we send through the http communication between the listener and Chromedirver, which is helpful to understand
Attached Files

Viewing all articles
Browse latest Browse all 1449

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>