Dim webBrowser1 As Object = New WebBrowser webBrowser1 = Process.Start(MemSite(CurrCell), ProcessWindowStyle.Maximized) Dim HtmlDoc As HtmlDocument = webBrowser1.Document Dim htmlElem As HtmlElement = HtmlDoc.All.Item(0) If htmlElem.TagName = "HTML" Then End If
Quote: 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 If End Sub Private 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 Function Function 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
Imports OpenQA.Selenium Imports OpenQA.Selenium.Chrome Imports OpenQA.Selenium.Support.UI Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim driver As New ChromeDriver driver.Navigate.GoToUrl("http://www.google.com") Dim searchBox As IWebElement searchBox = GetWebElement(driver, By.Name("q"), 10) searchBox.SendKeys("2001 something wonderful") searchBox.SendKeys(Keys.Enter) End Sub Private 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 Function End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)