1

Watinスクリプトで、「新しいIEのハンドルが現在のIEのハンドルと等しくない」という条件で別のブラウザーにアタッチしたい場合、私のコードは次のとおりです。

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'

ここで何が問題なのですか?

4

1 に答える 1

1

Watin が何であるかはわかりませんが、明らかにhandlehwndには異なる型 (stringIntPtr) があり、それらを と比較しても意味がありませんEquals

どちらが文字列であっても、次のように変換してみてくださいIntPtr

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

(ここからメソッドを取りました)。

于 2013-03-29T12:04:38.323 に答える