[VB]網頁自動傳值(Hub 和Node同一台)
想設計一個可以由自已設計的網頁,將網頁某個元件值帶入GOOGLE首頁搜詢框。 首先,需要先到NuGet下載 Selenium 下載完成後,就可以開始寫code啦 引用 Imports OpenQA.Selenium.Chrome Function SetUp(url As String, js As StringBuilder) Dim options As ChromeOptions = New ChromeOptions() options.AddArguments("disable-infobars") Dim driver = New ChromeDriver(options) driver.Manage().Window().Maximize() driver.Manage().Cookies.DeleteAllCookies() driver.Navigate().GoToUrl(url) driver.ExecuteScript(js.ToString) Return True End Function Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click url = "https://www.google.com/" js.Append("document.getElementsByName('q')[0].value='" + TextBox1.Text + "'") ...