2013-03-29 64 views
1

在华廷剧本我要附加到与条件的另一个浏览器 - “新IE的手柄不等于处理当前IE的”,这里是我的代码:谓语华廷Find.By方法

var hwnd = currentIE.hWnd; 
var newIE= Browser.AttachTo<IE>(Find.By("hwnd", handle => !handle.Equals(hwnd) )); 

Visual Studio有一个警告:

"suspicious comparison: there is no type in the solution which is inherited from both 'string' and 'System.IntPtr' 

这里有什么问题?

回答

1

我不知道华廷是什么,但显然handlehwnd有不同的类型(stringIntPtr),并没有指向他们Equals比较。

哪一个是一个字符串,你可以尝试将其转换为IntPtr

static IntPtr ParseIntPtr (string s) 
{ 
    s = s.Replace ("0x", ""); 
    return (IntPtr) int.Parse(s, System.Globalization.NumberStyles.AllowHexSpecifier); 
} 

(我把方法from here)。