小编Joh*_*vin的帖子

用于<label for ="x">的Selenium定位器

使用ASP.NET,标签ID非常不稳定,所以为了使我的测试更加健壮,我想通过标签文本定位元素.我已经和WatiN玩了一些并且完美地做到了这一点但是现在这个项目似乎有点死了所以我认为在决定框架之前我也会考虑Selenium.

我有html看起来像这样

<label for="ctl00_content_loginForm_ctl01_username">Username</label>:
<input type="text" id="ctl00_content_loginForm_ctl01_username" />
Run Code Online (Sandbox Code Playgroud)

我不想输入:

selenium.Type("ctl00_content_loginForm_ctl01_username", "xxx");
Run Code Online (Sandbox Code Playgroud)

这太依赖于身份证.在WatiN我会写:

browser.TextField(Find.ByLabelText("Username")).TypeText("xxx");
Run Code Online (Sandbox Code Playgroud)

有没有办法在Selenium做到这一点?

testing selenium watin web-testing selenium-rc

11
推荐指数
2
解决办法
4万
查看次数

统一处置对象

有没有办法让Unity将属性注入的对象作为拆解的一部分进行处理?

背景是我正在使用ASP.NET MVC 2,Unity和WCF的应用程序.我们编写了自己的MVC控制器工厂,它使用unity实例化控制器,并使用控制器公共属性的[Dependency]属性注入WCF代理.在页面生命周期结束时,调用控制器工厂的ReleaseController方法,并调用IUnityContainer.Teardown(theMvcController).此时控制器按预期处理,但我还需要处理注入的wcf代理.(实际上我需要对它们调用Close和/或Abort而不是Dispose但这是后来的问题.)

我当然可以覆盖控制器的Dispose方法并清理那里的代理,但我不希望控制器必须知道注入接口的生命周期,甚至是它们引用WCF代理.

如果我需要自己编写代码 - 什么是最好的扩展点?我很欣赏任何指针.

idisposable ioc-container unity-container wcf-proxy

7
推荐指数
1
解决办法
4391
查看次数

如何使用ADO从查询中检索所有错误和消息

当SQL批处理从例如print语句返回多个消息时,我只能使用ADO连接的Errors集合检索第一个消息.我如何获得其余的消息?

如果我运行此脚本:

Option Explicit
Dim conn
Set conn = CreateObject("ADODB.Connection")
conn.Provider = "SQLOLEDB"
conn.ConnectionString = "Data Source=(local);Integrated Security=SSPI;Initial Catalog=Master"
conn.Open

conn.Execute("print 'Foo'" & vbCrLf & "print 'Bar'" & vbCrLf & "raiserror ('xyz', 10, 127)")

Dim error
For Each error in conn.Errors
    MsgBox error.Description
Next
Run Code Online (Sandbox Code Playgroud)

然后我只回到"Foo",从不"Bar"或"xyz".

有没有办法获取剩余的消息?

sql-server vbscript ado

2
推荐指数
1
解决办法
4031
查看次数

在GNU Make 4中使用"bash -e"作为shell时,rm -f无法丢失文件

我有一个Makefile,如下所示:

.ONESHELL:
SHELL = /bin/bash
.SHELLFLAGS = -e

clean:
    rm -f foo

.PHONY: clean
Run Code Online (Sandbox Code Playgroud)

foo不存在.当我在Debian上运行它时,GNU Make 4.1我得到了这个错误:

rm -f foo
/bin/bash: rm -f foo: No such file or directory
Makefile:6: recipe for target 'clean' failed
make: *** [clean] Error 1
Run Code Online (Sandbox Code Playgroud)

当我在macOS上运行它时,GNU Make 3.81它按预期工作.如果我写-rm -f而不是,那没有区别rm -f.

为什么我会收到错误?bash -e -c "rm -f foo" ; echo $?在shell 0上运行打印在两个系统上.

我错过了什么吗?

bash makefile gnu-make

1
推荐指数
2
解决办法
112
查看次数