我尝试输入密码到WPF密码箱并获得
System.ArgumentException:编码的字符串只能用于a 密码。
/// <summary>
/// Type '********' in text box
/// </summary>
public string UIItemEdit1SendKeys = "nAI/+1YbLXAzMC+MylAiumF+gga6bwns";
再试一次是
Playback.EncryptText("admin")
这给出了同样的例外。 我正在使用VS 2013。 我似乎做了非常简单的事情,使用Coded UI Test Builder - Recorder输入用户名和密码。我可以记录但是在运行测试时我得到了上述参数 - 异常。
答案 0 :(得分:0)
如果您尝试使用sendkeys方法来设置密码,则可能会出现此异常。
您的Test对象类型可能具有Password属性。当您使用编码文本设置此属性时,它将自动解密
// Refer to your Parameter
uIPasswordEdit.Password = this.RecordedMethod1Params.UIPasswordEditPassword;
//Or Simply
uIPasswordEdit.Password = "nAI/+1YbLXAzMC+MylAiumF+gga6bwns";
如果没有看到.Password属性,则应该有.text属性。但是,请注意,你不能在那里使用你的加密字符串,你必须自己提供密码(当心,你会在这里妥协安全)。它如下所示,
//Use the Text Attribute
uIPasswordEdit.Text= "myActualPasswordHere";
如果无效则使用,sendkeys作为最后的手段
// Click the Password box to gain focus
Mouse.Click(uIPasswordEdit);
Keyboard.SendKeys("myActualPasswordHere");