我的代码中有这个:
Public Shared Async Function SingSongs3() As Task
ias.fireFoxDriver.Navigate.GoToUrl("https://www.youtube.com/watch?v=ifCWN5pJGIE")
'ias.NavigateTillComplete("https://www.youtube.com/watch?v=ifCWN5pJGIE")
Await Task.Delay(60000)
ias.fireFoxDriver.Navigate.GoToUrl("http://google.com")
End Function
这是一个警报。
它运作良好。问题是它并没有真正敲响警报。那是因为 firefoxdriver 会阻止任何带有声音的自动播放。
我可以去 about:config 并改变它,在那个季节,一切都很好。我可以做类似https://support.mozilla.org/en-US/kb/block-autoplay
但是,下次运行程序时,设置会返回。
我想知道有没有办法以编程方式更改设置,以便不阻止声音自动播放。
我正在考虑做类似的事情
https://tarunlalwani.com/post/change-profile-settings-at-runtime-firefox-selenium/
Dim Profile = fireFoxDriver.FirefoxProfile()
Profile.set_preference("media.autoplay.blocking.policy", 0)
但是,它不起作用。没有名为 FirefoxProfile 的类是 firefoxdriver 的成员
我Imports OpenQA.Selenium.Firefox
在上面有进口。也没有名为 webdriver 的类。
我尝试使用这个类。
https://www.selenium.dev/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_Firefox_FirefoxOptions.htm
不知道我应该怎么做。