简体   繁体   中英

How do you enable Silverlight plugin using Java Selenium?

I am running selenium tests in java on a website that is using Silverlight:

One test example is:

   public double getVideoBitrate()
   {
      return Double.valueOf(executeBridgeCommand("Diagnostics.CurrentBitrate").toString());
   }

the Problem I've run into is that when running on a Jenkins slave, i have no guarantee that silverlight is active so my tests fail. How do I activate it in the browser? These commands (at least for Firefox) look as if they are what i'm looking, but I don't know what preferences to set or how to find them for silverlight.

FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("browser.download.folderList",2);
firefoxProfile.setPreference("pdfjs.disabled", true);
firefoxProfile.setPreference("pdfjs.firstRun", false);

(copied from Selenium disable plugins in firefox profile )

I also need to ensure that silverlight is active in Chrome and IE as well.

If you are simply validating that Silverlight is enabled, then you should be able to do this:

WebElement silverlightElement = driver.findElement(By.cssSelector("object[type='application/x-silverlight-2']");

Then do what you will with it.

However , please note that this is the extent that you can do with Selenium. You can validate the attributes that are revealed in the HTML, but anything inside of the Object, is out of Selenium's Scope. Selenium cannot automate anything embedded like PDF, Flash, Java Applets, Silverlight, etc.

有一个Silverlight Selenium插件可以获取诸如视频速率之类的信息,并且还可以执行其他操作。

好吧,由于Microsoft不再支持Silverlight,所以我的公司开始使用Flashplayer,所以现在这个问题尚无定论。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM