I have to get the url address of the page which i have opened by executing click eve开发者_StackOverflow中文版nt.
It works fine as the link was in javascript, it opens a popup, now i want to have the url of this popup is there any way to grab the url address..
You can use the IE.InternetExplorers collection.
Example: Write out the URLs of all open IE windows
foreach (IE currIE in IE.InternetExplorers())
{
Console.WriteLine("URL: " + currIE.Url);
}
If you have an idea on what the URL should be, using a RegEx to find the correct IE instance is hopefully straight forward. If you have no idea what the URL of the popup is, you could create a list of the URLs before opening the popup, open the popup and compare the new list to the old list to figure out the newly opened URL.
Edit: Also, once you know the URL, you'll use the AttachTo method to work with the newly found window. Read more here: http://watinandmore.blogspot.com/2010/01/browserattachto-and-iattachto.html
The above is NUnit and Watin 2.0.
May be this help you.
string Current_Url= HttpContext.Current.Request.Url.Host;
If it is alright to open the popup and then get the URL, this mechanism might work for you:
Link ReportsLink = browserinstance.Link(Find.ById("ctl00_NavigationTab_tabLink5"));
ReportsLink.Click();
Browser newbrowser = Browser.AttachTo(browserinstance.GetType(), Find.ByTitle("BusinessObjects InfoView"));
string url = newbrowser.Url;
newbrowser.Close();
精彩评论