在IE9中使用IE驱动程序时,偶尔Click方法只会选择一个按钮,它不会执行Click()的操作.请注意,这只会偶尔发生,所以我不认为这是代码问题.在Firefox4上使用Firefox驱动程序没有问题.我也有一个问题,偶尔也没有找到元素,但只在IE中再次发现,而不是Firefox.
if (Driver.FindElement(By.Name("username")) == null) {
//sometimes gets here in IE, never gets here in Firefox
}
Driver.FindElement(By.Name("username")).SendKeys(username);
Driver.FindElement(By.Name("surname")).SendKeys(surname);
Driver.FindElement(By.Name("firstname")).SendKeys(firstname);
string url = Driver.Url;
Driver.FindElement(By.Name("cmd")).Click();
if (Driver.Url == url) {
//if the page didnt change, click the link again
Driver.FindElement(By.Name("cmd")).Click();
}
Run Code Online (Sandbox Code Playgroud)
我已经看到了类似的问题(http://stackoverflow.com/questions/4737205/selenium-webdriver-ie-button-issue),但我没有动态生成的ID.
有没有一种简单的方法来解析 powershell 脚本文件中的参数
param(
[string]$name,
[string]$template
)
Run Code Online (Sandbox Code Playgroud)
我已经开始阅读该文件,想知道是否有更好的方法,也许通过 help/man 命令?
class PowerShellParameter {
public string Name;
public string Type;
public string Default;
}
string[] lines = File.ReadAllLines(path);
bool inparamblock = false;
for (int i = 0; i < lines.Length; i++) {
if (lines[i].Contains("param")) {
inparamblock = true;
} else if (inparamblock) {
new PowerShellParameter(...)
if (lines[i].Contains(")")) {
break;
}
}
}
Run Code Online (Sandbox Code Playgroud)