- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 PlayFramework 2.5 的 WithBrowser
类编写 Selenium 测试。
类似这样的事情:
public class BrowserFunctionalTest extends WithBrowser {
@Test
public void runInBrowser() {
browser.goTo("/");
assertNotNull(browser.$("title").getText());
}
}
但是,我希望能够至少为 CSS 错误设置自定义错误处理程序,因为它们会向我的控制台发送垃圾邮件。由于它们来自 boostrap,我无法摆脱它们。
我尝试像这样设置记录器的日志级别:
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(java.util.logging.Level.SEVERE);
System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog", "fatal");
Fluentlenium 文档告诉我重写 getDefaultDriver 方法,但这似乎不适用于此处。而且我无法直接获取 WebClient,因为该字段没有 getter。
最佳答案
使用WithBrowser
帮助程序类时,您可以重写provideBrowser
来自定义TestBrowser
的配置方式。还有一些其他细节,但下面的代码几乎展示了如何做到这一点:
import static org.junit.Assert.*;
import com.gargoylesoftware.htmlunit.WebClient;
import org.junit.Test;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import play.test.Helpers;
import play.test.TestBrowser;
import play.test.WithBrowser;
public class BrowserFunctionalTest extends WithBrowser {
// Just to make the WebClient visible at the test. Of course, this
// could be an independent class to be reused by other tests or you
// can create your own class that extends WithBrowser and hide all
// the details from your tests.
public static class CustomHtmlUnitDriver extends HtmlUnitDriver {
@Override
public WebClient getWebClient() {
return super.getWebClient();
}
}
@Override
protected TestBrowser provideBrowser(int port) {
// Here you need to create the TestBrowser for the class above.
TestBrowser browser = Helpers.testBrowser(CustomHtmlUnitDriver.class, port);
CustomHtmlUnitDriver driver = (CustomHtmlUnitDriver)browser.getDriver();
WebClient client = driver.getWebClient();
// do whatever you want with the WebClient
return browser;
}
@Test
public void runInBrowser() {
browser.goTo("/");
assertNotNull(browser.$("title").getText());
}
}
现在,由于您已经可以访问 WebClient
,因此您可以按照此讨论中的说明进行操作:
关于java - Play 2.5 和 Fluentlenium : how to turn HtmlUnit warnings off,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37821376/
我正在尝试在不同的浏览器驱动程序中运行 Fluentlenium。我想我需要从 Fluentlenium 配置 getDefaultDriver(),但我不太确定该怎么做。任何示例代码都会很棒。这是我
我正在使用 fluentlenium 对我的应用程序进行测试,但出现了一些错误。我正在使用 Play Framework 和 Slickgrid 来创建我的网格。 Slickgrid 在 javasc
我有一个 Cucumber 和 Fluentlenium 项目,当我运行 CucumberRunner 时该项目无法启动。它只是跳过所有测试。我试图在互联网上找到解决方案,但到目前为止还没有解决问题。
我正在寻找使用 Fluentlenium 和 DropZone.js ( http://www.dropzonejs.com/ ) 编写一个上传文件的测试。 Dropzone.js 在模式下工作,然后
Chrome 59 有 removed support for https://user:password@example.com URLs . 我有一个测试正在使用这个功能,但现在已经坏了,所以我试
我正在尝试使用 PlayFramework 2.5 的 WithBrowser 类编写 Selenium 测试。 类似这样的事情: public class BrowserFunctionalTest
我是一名优秀的程序员,十分优秀!