- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 ScalaTest 的 Selenium DSL 编写 Selenium 测试,但我遇到了无法解释的超时。更复杂的是,它们似乎只在某些时候发生。
每当我在页面加载或某些 Javascript 呈现后访问元素时,就会出现问题。它看起来像这样:
click on "editEmployee"
eventually {
textField(name("firstName")).value = "Steve"
}
override implicit val patienceConfig: PatienceConfig =
PatienceConfig(timeout = Span(5, Seconds), interval = Span(50, Millis))
- should not display the old data after an employee was edited *** FAILED ***
The code passed to eventually never returned normally. Attempted 1 times over 10.023253653000001 seconds.
Last failure message: WebElement 'firstName' not found.. (EditOwnerTest.scala:24)
click
导致一些渲染,并且文本字段可能无法立即使用。但是,尝试找到它不应该花费 10 秒,对吧?
click on "editEmployee"
eventually {
find(name("firstName")).value // from ScalaTest's `OptionValues`
}
textField(name("firstName")).value = "Steve"
textField
),最终调用
webElement
在某一点。解决方法有效的原因是它不调用
webElement
.
webElement
定义如下:
def webElement(implicit driver: WebDriver, pos: source.Position = implicitly[source.Position]): WebElement = {
try {
driver.findElement(by)
}
catch {
case e: org.openqa.selenium.NoSuchElementException =>
// the following is avoid the suite instance to be bound/dragged into the messageFun, which can cause serialization problem.
val queryStringValue = queryString
throw new TestFailedException(
(_: StackDepthException) => Some("WebElement '" + queryStringValue + "' not found."),
Some(e),
pos
)
}
}
find
的多余调用。一直以来,因为它很容易被遗忘,尤其是因为,正如我所说,错误仅在某些时候发生。 (我无法确定行为何时发生以及何时不发生。)
最佳答案
很明显,textField(name("firstName")).value = "Steve"
最终调用 WebElement
正如你所发现的。
由于操作中的问题发生在涉及 Web 元素的地方(这反过来意味着涉及 webdriver),我认为可以安全地假设该问题与 Web 驱动程序上的隐式等待有关。
implicitlyWait(Span(0, Seconds))
def implicitlyWait(timeout: Span)(implicit driver: WebDriver): Unit = {
driver.manage.timeouts.implicitlyWait(timeout.totalNanos, TimeUnit.NANOSECONDS)
}
name("firstName")
最终的值为
Query {Val by = By.className("firstName") }
.
def name(elementName: String): NameQuery = new NameQuery(elementName)
case class NameQuery(queryString: String) extends Query { val by = By.name(queryString) }
Query
馈送到
textField
调用
Query.webElement
的方法如下。
def textField(query: Query)(implicit driver: WebDriver, pos: source.Position): TextField = new TextField(query.webElement)(pos)
sealed trait Query extends Product with Serializable {
val by: By
val queryString: String
def webElement(implicit driver: WebDriver, pos: source.Position = implicitly[source.Position]): WebElement = {
try {
driver.findElement(by)
}
catch {
case e: org.openqa.selenium.NoSuchElementException =>
// the following is avoid the suite instance to be bound/dragged into the messageFun, which can cause serialization problem.
val queryStringValue = queryString
throw new TestFailedException(
(_: StackDepthException) => Some("WebElement '" + queryStringValue + "' not found."),
Some(e),
pos
)
}
}
}
关于scala - ScalaTest 的 Selenium DSL 的奇怪超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46189873/
我们有一个系统,其行为由许多 XML 文件定义。(大约 50 个不同的 XML 文件,每个文件管理子系统的行为。) 出于遗留原因,XML 文件采用自定义格式,旨在方便系统中的各种组件使用。 自定义格式
我发送的 json 请求是: Given url applicationURL And path 'applications' And header Authorization = subscribe
默认情况下,生成的 XText 工件会从我的 DSL 生成代码到默认 socket (默认为 src-gen 文件夹)。我知道您可以在 fsa.generateFile("myfile.txt", "
我的论文主题一般是关于领域特定语言的,我想专注于外部或内部 DSL 的设计或实现,但我什至无法思考或开始,因为我在理解 DSL 的概念方面遇到了问题.. 我已经阅读并收集了很多关于这个问题的论文和调查
我有一个 Xtext 项目和几个示例 DSL 文件。我可以使用“示例 Ecore 模型编辑器”打开这些文件并验证它是否符合 Xtext 生成的元模型。但是,由于 DSL 文件未被识别为 Ecore,我
当我学习一些 DSL 时,我意识到 Rebol 中的 Parse 方言可以是一个很好的词法分析器和解析器。 the Parse tutorial 有一个很好的例子: expr: [ter
我正在考虑使用亚马逊云服务(EC2、S3 等)进行托管。我一直在查看可以指定用于配置各种实例的 JSON 元数据,我担心它的复杂性。是否有一个 dsl 可以生成有效的 JSON 元数据并且更重要的是验
我可能会因为这个而被否决,但无论如何我都会试试运气。 我真的找不到 Elastic Search 查询 DSL 的完整形式“DSL”的任何链接,甚至在 Elastic Search 网站上也找不到 h
这个问题可能是复合的,让我扩展一下: 是否存在设计器( stub /框架/元设计器)来创建基于 .NET 对象公共(public) bool 属性的 AND/OR 规则?保存为任何 DSL/Boo/.
与 anko 一样你可以这样写回调函数: alert { title = "" message = "" yesButton { toast("Yes")
我有一个像下面这样的原始聚合脚本,但是很难将其转换为elasticsearch dsl。 我已阅读该文档并找到描述,说我们可以使用.bucket()、. metric()和.pipeline()方法来
如何将这个 gradle groovy 片段转换为 gradle kotlin dsl 而不是非常冗长? test { systemProperties System.getPropertie
这个问题是 ANY operator with jOOQ 的衍生问题和 Are arrays optimized in jOOQ & PostgreSQL? . 我有一个Field field和Lis
我创建了内部 DSL,并且会重载 DefaultGroovyMethods 中的 any() 方法。 class RulesProcessor { } Any live cell with fewer
我正在尝试使用 Gradle 使用 Kotlin 和 Java 11 构建一个简单的 JavaFX 11 程序,按照说明 here .但是,此页面使用 Gradle 的 Groovy DSL,而我正在
如何将这个 gradle groovy 片段转换为 gradle kotlin dsl 而不是非常冗长? test { systemProperties System.getPropertie
我是 Camel 的新手,我仍在学习它,根据我的理解,你可以在 Spring DSL 中做与 Java DSL 相同的事情。我想知道如何将一种转换为另一种?我经常看到 Java 中的例子,但想要 最佳
我正在尝试通过 Groovy 代码为 Jenkins Job DSL 插件创建 ListView 。运行后, View 已创建,但不会添加任何作业。以下代码段之前的代码创建了构建和部署作业,并且在调用
对于 Jenkins 作业 DSL,我试图为作业选择特定的 ssh 代理(插件)键(在包装器上下文中使用 sshAgent 关键字)。我们安装了 Jenkins ssh 代理插件并设置了几个 key
我必须为非程序员(我们公司的客户)创建一个 DSL,它需要提供一些更高级别的语言功能(循环、条件表达式、变量...... - 所以它不仅仅是一个“简单”的 DSL)。 使用 DSL 应该很容易;人们应
我是一名优秀的程序员,十分优秀!