Const strKeyPath =Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice Const strValueName =Progid Dim strValue,objRegistry,i strValue = Nothing Dim blist(6,1)'浏览器列表: blist(0,0)=Intermet Explorer:blist(0,1)=ie blist(1,0)=Edge:blist(1,1)=appxq0fevzme2pys62n3e0fbqa7peapykr8v blist(2,0)=Firefox:blist(2,1 )=firefox blist(3,0)=Chrome:blist(3,1)=chrome blist(4,0)= Safari:blist(4,1)=safari blist(5,0)=Avant:blist(5,1)=browserexeurl blist(6,0)=Opera:blist(6,1)=opera objRegistry = GetObject(winmgmts:\\.\root\default:StdRegProv ) objRegistry.GetStringValue(HKEY_CURRENT_USER,strKeyPath,strValueName,strValue) 如果strValue什么都没有那么 浏览器=Intermet Explorer:退出功能 否则 对于i = 0到UBound(blist,1) 如果是InStr(1,s trValue,blist(i,1),vbTextCompare)然后Browser = blist(i,0):退出函数 下一页 结束如果 浏览器=未知的网络浏览器'(签名:'& strValue& ') 结束功能Private Sub NavWeb() Browser() 'Dim driver As New InternetExplorerDriver 'Dim driver As New ChromeDriver Dim driver As New EdgeDriver 'Dim driver As New SafariDriver driver.Navigate.GoToUrl(MemSite(CurrCell)) Dim HtmlElem As IWebElement HtmlElem = GetWebElement(driver, By.TagName("html"), 20) If HtmlElem.TagName = "html" Then MsgBox("Fond HTML page in " & "Browser: " & Browser()) End IfEnd SubPrivate Overloads Function GetWebElement(ByVal webDriver As IWebDriver, ByVal definition As By, ByVal timeoutSeconds As Integer) As IWebElement Dim wait As New WebDriverWait(webDriver, TimeSpan.FromSeconds(timeoutSeconds)) wait.Until(Function(d) Return d.FindElement(definition).Enabled And d.FindElement(definition).Displayed End Function) Return webDriver.FindElement(definition)End FunctionFunction Browser() Const HKEY_CURRENT_USER = &H80000001 Const strKeyPath = "Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice" Const strValueName = "Progid" Dim strValue, objRegistry, i strValue = Nothing Dim blist(6, 1) 'Browser list: blist(0, 0) = "Intermet Explorer" : blist(0, 1) = "ie" blist(1, 0) = "Edge" : blist(1, 1) = "appxq0fevzme2pys62n3e0fbqa7peapykr8v" blist(2, 0) = "Firefox" : blist(2, 1) = "firefox" blist(3, 0) = "Chrome" : blist(3, 1) = "chrome" blist(4, 0) = "Safari" : blist(4, 1) = "safari" blist(5, 0) = "Avant" : blist(5, 1) = "browserexeurl" blist(6, 0) = "Opera" : blist(6, 1) = "opera" objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv") objRegistry.GetStringValue(HKEY_CURRENT_USER, strKeyPath, strValueName, strValue) If strValue Is Nothing Then Browser = "Intermet Explorer" : Exit Function Else For i = 0 To UBound(blist, 1) If InStr(1, strValue, blist(i, 1), vbTextCompare) Then Browser = blist(i, 0) : Exit Function Next End If Browser = "Unknown web browser" '(signature: '" & strValue & "')"End Function 这篇关于Vb net:如何获得htmldocument&来自默认Web浏览器的活动htmlelements的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-27 04:30