How to get rid of “allow <website> to run 'silverlight'?” alert on firefox using firefoxprofile in webdriver

坚强是说给别人听的谎言 提交于 2019-12-11 03:35:55

问题


While using robot api's to drag and drop my mouse positions are being disturbed(running firefox in full screen mode) by an alert which asks "Allow to run silverlight?". Even my webdriver api's are getting affected due to this alert as the click intended to happen on one button performs on another.

I am using WebDriver to automate my scenario, combined with robot api for drag and drop. Is there a way i can set something in firefox profile so that this alert won't appear?

Below image shows the alert

https://drive.google.com/file/d/0B36CJTZFg52aUFhvWmZIVzNleEk/view?usp=sharing


回答1:


You can create new firefox profile

http://www.toolsqa.com/selenium-webdriver/custom-firefox-profile/

By opening firefox profile manager, and pressing add profile button and you can name it. Than you need to open that profile in FireFox, download Silverlight plugin, install it, and go to firefox plugins manager

https://helpdesk.contentraven.com/hc/en-us/articles/201455107-Mozilla-Firefox-and-Silverlight-Plug-In

in manager you will have to set silverlight plugin as Always Activate.

Then you have to just call this profile when you are invoking driver:

ProfilesIni profile = new ProfilesIni();

FirefoxProfile your_profile = profile.getProfile("<name of your profile>");

WebDriver driver = new FirefoxDriver(your_profile);



回答2:


On Windows you can do:

// Enable Silverlight
profile.setPreference("plugin.state.npctrl", 2);

And on OSX:

// Enable Silverlight
profile.setPreference("plugin.state.silverlight", 2);

On Windows, the DLL name is npctrl.dll, so I believe that's where the 'npctrl' comes from. You can see this from:

about:plugins

For Linux you will have to check. Open two tabs one for:

about:addons

And the other for:

about:config

In about:addons enable the Silverlight plugin to be Activated Always.

In about:config filter by 'plugins.state'. The item that changes when you change the activation state in about:addons is the one you add to add to the FireFox profile.



来源:https://stackoverflow.com/questions/26843852/how-to-get-rid-of-allow-website-to-run-silverlight-alert-on-firefox-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!