简体   繁体   English

如何使用Java Selenium启用Silverlight插件?

[英]How do you enable Silverlight plugin using Java Selenium?

I am running selenium tests in java on a website that is using Silverlight: 我正在使用Silverlight的网站上以Java运行硒测试:

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. 我遇到的问题是,在Jenkins从站上运行时,我无法保证silverlight处于活动状态,因此我的测试失败。 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. 这些命令(至少对于Firefox)看起来像是我正在寻找的命令,但是我不知道要设置哪些首选项或如何为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 ) (复制自firefox配置文件中的Selenium disable插件

I also need to ensure that silverlight is active in Chrome and IE as well. 我还需要确保Silverlight在Chrome和IE中也处于活动状态。

If you are simply validating that Silverlight is enabled, then you should be able to do this: 如果您只是在验证是否启用了Silverlight,那么您应该能够这样做:

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. 但是 ,请注意,这就是您可以使用Selenium的程度。 You can validate the attributes that are revealed in the HTML, but anything inside of the Object, is out of Selenium's Scope. 您可以验证HTML中显示的属性,但对象内部的任何内容都超出Selenium的范围。 Selenium cannot automate anything embedded like PDF, Flash, Java Applets, Silverlight, etc. Selenium无法自动化嵌入式的任何内容,例如PDF,Flash,Java Applets,Silverlight等。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 你如何在用java编写的selenium webdriver程序中使用firefox插件? - How do you use a firefox plugin within a selenium webdriver program written in java? 使用Grizzly的嵌入式Java服务器:如何启用http2 - Embedded Java server using Grizzly: How do you enable http2 如何在任意Java应用程序中启用抗锯齿? - How do you enable anti aliasing in arbitrary Java apps? 你如何在java selenium中使用PageObjects和@FindBy执行javascript元素 - How do you execute javascript element using PageObjects and @FindBy in java selenium 在源代码中使用 selenium 时,如何从命令行编译 java 程序? - How do you compile a java program from the command line while using selenium in the source code? 如何将java注释处理器集成到java插件中 - How do you integrate the java annotation processor into the java plugin 您如何让Maven swagger Codegen插件使用继承生成Java类? - How do you have the maven swagger codegen plugin generate Java classes using inheritance? 如何在Java中使用硒仅加载页面上的某些元素 - How do you load only certain elements on a page with selenium in Java 如何判断 Selenium for Java 中是否选中了复选框? - How do you tell if a checkbox is selected in Selenium for Java? 在Ubuntu机器上运行的Selenium服务器上的Firefox中启用Java插件 - Enable java plugin in Firefox on a selenium server running on a Ubuntu machine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM