2017-11-19 2 views
1

Ich habe zahlreiche Lösungen für C# gesehen, aber ich konnte es nicht in VB.NET arbeiten. Vielleicht initialisiere ich es falsch? Ich möchte JavaScript über eine geladene URL im Chrometreiber ausführen.vb.net - Ausführen Selen ChromeDriver Javascript

Mein Code so weit:

Dim chromeOptions As New OpenQA.Selenium.Chrome.ChromeOptions() 

chromeOptions.AddUserProfilePreference("profile.default_content_setting_values.images", 2) 

Dim driverService = ChromeDriverService.CreateDefaultService() 

driverService.HideCommandPromptWindow = True 

driver = New ChromeDriver(driverService, chromeOptions) 

Dim js As IJavaScriptExecutor = TryCast(driver, IJavaScriptExecutor) 

driver.Navigate.GoToUrl("https://www.google.com/") 

js.ExecuteScript("alert('hello world');") 

Es ist die Ausführung nicht. Irgendwelche Hilfe, bitte? :)

Antwort

1

Fixed it. nur an die Spitze des

Imports OpenQA.Selenium.Support.Extensions 

Code hinzufügen und driver.ExecuteJavaScript ("alert (0);")