473,396 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Watin: BrowserNotFoundException on Browser.Attach<IE>(Find.ByURL(uri));

1
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:
Expand|Select|Wrap|Line Numbers
  1. private void GetHtmlCode()
  2. {
  3.     string uri = GetTargetURI();
  4.     if(!string.IsNullOrEmpty(uri))
  5.     {
  6.         IE ie = IE.AttachTo<IE>(Find.ByUrl(uri));
  7.         htmlCode = ie.Eval(JavaScriptToRun);
  8.     }
  9.     else
  10.     {
  11.         MessageBox.Show("Target page is not opened",
  12.                         "Notification", MessageBoxButtons.OK);
  13.     }
  14. }
And there's a method for getting URI:
Expand|Select|Wrap|Line Numbers
  1. private string GetTargetURI() //проверка URL
  2. {
  3.     Regex reg;
  4.     Match match;
  5.     foreach(SHDocVw.InternetExplorer ie in shellWindows)
  6.     {
  7.         reg = new Regex(patternURL);
  8.         match = reg.Match(ie.LocationURL.ToString());
  9.         if (!string.IsNullOrEmpty(match.Value))
  10.         {
  11.             pageURL = ie.LocationURL.ToString();
  12.             return pageURL;
  13.         }
  14.         pageURL = string.Empty;              
  15.     }
  16.     return pageURL;
- so the URI is completely correct or empty.

The problem is
Expand|Select|Wrap|Line Numbers
  1. IE ie = IE.AttachTo<IE>(Find.ByUrl(uri));
always throws
Expand|Select|Wrap|Line Numbers
  1. WatiN.Core.Exceptions.BrowserNotFoundException: Could not find an IE window matching constraint: Attribute 'href' equals uri '%my_target_URI%'. Search expired after '30' seconds.
I've googled a lot, but still didn't find any solution :(
Can anyone help please?
Thanks.
Oct 28 '12 #1
0 1647

Sign in to post your reply or Sign up for a free account.

Similar topics

5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.