Hello. I'm trying to find opened webpage by URI and to launch JS on it. I found some samples and wrote simple method. That's how it look:
And there's a method for getting URI:
- so the URI is completely correct or empty.
The problem is
always throws
I've googled a lot, but still didn't find any solution :(
Can anyone help please?
Thanks.
Code:
private void GetHtmlCode()
{
string uri = GetTargetURI();
if(!string.IsNullOrEmpty(uri))
{
IE ie = IE.AttachTo<IE>(Find.ByUrl(uri));
htmlCode = ie.Eval(JavaScriptToRun);
}
else
{
MessageBox.Show("Target page is not opened",
"Notification", MessageBoxButtons.OK);
}
}
Code:
private string GetTargetURI() //проверка URL
{
Regex reg;
Match match;
foreach(SHDocVw.InternetExplorer ie in shellWindows)
{
reg = new Regex(patternURL);
match = reg.Match(ie.LocationURL.ToString());
if (!string.IsNullOrEmpty(match.Value))
{
pageURL = ie.LocationURL.ToString();
return pageURL;
}
pageURL = string.Empty;
}
return pageURL;
}
The problem is
Code:
IE ie = IE.AttachTo<IE>(Find.ByUrl(uri));
Code:
WatiN.Core.Exceptions.BrowserNotFoundException: Could not find an IE window matching constraint: Attribute 'href' equals uri '%my_target_URI%'. Search expired after '30' seconds.
Can anyone help please?
Thanks.