I have a Silverlight 5 application which shows a Dynamics CRM 2013 webpage (list of accounts) in a Silverlight webbrowser control. When the user clicks on one entity record in the list the detail view of that record should open in the same browser. It is opened in a new browser window instead. How can I make the Silverlight webbrowser open it in the same window? In a standard Internet Explorer it is opened in the same browser window.
I found a solution how to achieve that in a .Net webbrowser control. However this is different from the Silverlight webbrowser control I have. Especially the "Document" property and the events "DocumentCompleted" and "NewWindow" are missing.
I use Internet Explorer 11 on a Windows 7 machine to test it. Any hint is highly appreciated.
Cheers,
Arne
Try this:
HtmlPage.Window.Navigate(new Uri("the address here"), "_self");
The key is the second parameter "_self", which means that you want to open the link on the same page. You can also use "_blank" for new tab or "_top" to put it on top of the hierarchy.
Useful links
http://msdn.microsoft.com/en-us/library/cc189809(v=vs.95).aspx
http://www.w3schools.com/jsref/met_win_open.asp
Hope it helps
Related
Issue: My selenium script is not recognizing and closing a dialog box that pops up when I redirect to a URl that contains file to download. The attached image shows the dialog I am referring to.
I know this has been asked a million times and I have spent at least 24 hours researching and trying other suggestions posted across the web but with no success. I am hoping the attached image will clarify which Firefox dialog box I am referring too.
I have tried the following solutions
1. Creating IAlerts (Alert element is not found)
2. Searching by trying to find the element by xpath (xpath to cancel was not found)
3. WindowsHandler Method (was not able to figure out the window name)
Any help on this would be greatly appreciated. Thank You in advance!
FireFox Dialog
There are several types of "popups".
Javascript dialogs - These are NOT HTML dialogs but are instead Javascript created dialogs. These consist of alert(), confirm(), and prompt() and can be handled with Alert.
HTML dialogs - These take on various forms depending on how they are formatted. If you right-click on the dialog and see the typical context menu for your browser, then it's an HTML dialog. They are part of the DOM of the current page so you can use Selenium to access this just as you would any other page (e.g., no window handles needed).
Browser window - These are actually another browser window that pops up and may look like a dialog, depending on how it's formatted. It's different than an HTML dialog because it can be moved outside of the current browser page frame. You will need to use window handles to access these windows as you would another tab in the browser. Once you get ahold of the window handle, you can access the HTML of the page like any other page.
Browser dialog - these take on various forms but are akin to System dialogs. They are not made up of HTML so they cannot be accessed by Selenium. Other than using a library to access them, you can interact with them in a limited fashion by sending keys such as <SPACE>, <TAB>, <ENTER>, etc.
What you have pictured is a (4) browser dialog. They it takes on different forms depending on the browser you do the action on. Your best course of action is probably send keys. Sometimes, depending on the browser, you can specify settings to autodownload a file to a specific location so that the dialog doesn't come up. I've never used this so I can't direct you there.
I was able to find and close a download dialog box by checking the amount of open windows after the dialog appears. This solution worked for me.
Find a link to open a dialog and click it:
var link = MyBrowser.Driver.FindElement(OpenQA.Selenium.By.Id("Button"));
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
js.ExecuteScript("arguments[0].click();", link);
Get the new window count after the dialog opens:
var newWindowCount = MyBrowser.Driver.WindowHandles.Count;
Switch to the newly opened dialog and close it:
MyBrowser.Driver.SwitchTo().Window(MyBrowser.Driver.WindowHandles[newWindowCount-1]);
MyBrowser.Driver.Close();
i am working on an winform application in which i used watiN. Now when i open my website in default winform browser control, than its design become worst. So i want to use Webkit Browser control in my winform app.
I don't know how to use Webkit Browser in watiN.
I also tried to use GeckoFX for it , but it is also not supporting in watiN.
Can anybody please tell me how can i use other browser controls in watin except Default winform browser control.
I am stucked here
Thanks in Advance
I'm in a trouble trying to fix some problem.. I have a program with Webbrowser control inside it.
It automates crawling process from some website. The problem is that I cannot fix webbrowser after recent website changes.
They have changed page navigation on website. And when I do actions MANUALLY in webbrowser (in my app) it doesn't go to the next/previous page on website. It does nothing... Whereas it works properly in IE 7/8/9 (only scripting errors thrown this time).
So does it mean that Webbrowser is not fully similar to IE??
I'm sorry for not showing source codes here, I think it wouldn't help here. Which way should I go to troubleshoot it? Why page navigation is not working in Webbrowser control?
I tried to simply put Webbrowser on a Window Form in new project and tried to navigate page 2/3/../10 in the website catalog, but it simply changes page number and doesn't navigate to it...
EDIT: Website doesn't work propely even if I do actions manually in webbrowser using mouse clicks.. but works in IE.
EDIT2: I might be not clear in my question. The problem is that I cannot use website even Manually with mouseclicks via my Webbrowser control in app. It changes page number after I click on it, but it doesn't navigate to that page. It stays silent. I'm sure that AllowNavigation property is true. It worked just yesterday and stopped after website changes today... Please tell me which way should I go to troubleshoot it.. I thought that Webbrowser control acts the same way as Internet Explorer.. Any help from you highly appreciated! Thanks
EDIT3: Strange thing... i just loaded Extended Webbrowser and navigated to that website. Page navigation panel doesn't work there also.. Is it a bug on their side or some type of guard from crawlers? What do you think?
(http://www.codeproject.com/KB/cpp/ExtendedWebBrowser.aspx)
I'm sure this isn't the answer your want but using the webbrowser control to scrape websites is very painful to maintain.
Instead use the HttpWebRequest and HttpWebRepsonse objects to recreate the calls to the webserver.
You can use Fiddler (http://www.fiddler2.com/fiddler2) and your browser to record your web sessions and recreate them in code.
You can setup your webbrowser control to disable a number of features including navigation.
I.e. to disable nav in the C# WebBrowser control:
webBrowser1.AllowNavigation = false;
I'd double check that you're not doing anything like this.
I had the same issue with a certain web site that recently changed its format. It has to do with the version of IE used by the control.
Simply force the IE version used to the latest (in my case 9). Setting the appropriate registry item to 9999 for my application worked; see: Webbrowser control behaving different than IE
I'm new in automated testing (Watin for IE) and i came across with some issues automating the People picker of sharepoint. I can't take the controls within the pop up because the pop up blocks main page (blocking also Intenet Explorer Developer Tools). Someone knows how can i do it or at least the name of the controls for IE?
Thanks
If it is a modal dialog that is getting you bothered, you can try this.
Open the SharePoint site in Firefox and then open the People-Picker. In firefox you would have the URL displayed for the modal dialog too. And from there you use the URL to open it in a new browser tab directly and use a web development tools plugin to view the DOM.
i have a link that when we click will produce a windows form that prompt us to download.Is there a way using watin for us to attach to this form and click the button?Can someone please direct me to the correct way?
What do you mean by saying, that clicking a linkd produces a windows form? Isn't it just a separate IE window, probably created by js window.open? If so, then you need to create separate WatiN IE instance by attaching to that window. For example, if you want to control internet explorer window with title "My popup", you can do it that way:
var popup = IE.AttachTo<IE>(Find.ByTitle("My popup"))
You can find IE windows using constraints created using: Find.ByUrl, Find.ByUri, Find.By("hwnd", windowHandle) and mentioned Find.ByTitle.