[英]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.